Skip to content

Commit

Permalink
fix(db): usage & date are reserved words in SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
hippothomas committed Jan 8, 2024
1 parent bb9787f commit d8c6a73
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions migrations/Version20240108003410.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240108003410 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE service_usage RENAME COLUMN usage TO daily_usage');
$this->addSql('ALTER TABLE service_usage RENAME COLUMN date TO date_usage');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE service_usage RENAME COLUMN daily_usage TO usage');
$this->addSql('ALTER TABLE service_usage RENAME COLUMN date_usage TO date');
}
}
4 changes: 2 additions & 2 deletions src/Entity/ServiceUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class ServiceUsage
#[ORM\JoinColumn(nullable: false)]
private ?User $account = null;

#[ORM\Column]
#[ORM\Column(name: 'daily_usage')]
private ?int $usage = null;

#[ORM\Column(type: Types::DATE_MUTABLE)]
#[ORM\Column(name: 'date_usage', type: Types::DATE_MUTABLE)]
private ?DateTimeInterface $date = null;

#[ORM\Column(type: Types::DATETIME_MUTABLE)]
Expand Down

0 comments on commit d8c6a73

Please sign in to comment.