migrations/Version20190828113314.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20190828113314 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add time entry table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  19.         $this->addSql('CREATE TABLE time_entry (
  20.             id UUID NOT NULL, 
  21.             user_id UUID DEFAULT NULL, 
  22.             project_id UUID DEFAULT NULL, 
  23.             timer_start TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, 
  24.             timer_end TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, 
  25.             description TEXT DEFAULT NULL, 
  26.         PRIMARY KEY(id))');
  27.         $this->addSql('CREATE INDEX IDX_6E537C0CA76ED395 ON time_entry (user_id)');
  28.         $this->addSql('CREATE INDEX IDX_6E537C0C166D1F9C ON time_entry (project_id)');
  29.         $this->addSql('COMMENT ON COLUMN time_entry.id IS \'(DC2Type:uuid)\'');
  30.         $this->addSql('COMMENT ON COLUMN time_entry.user_id IS \'(DC2Type:uuid)\'');
  31.         $this->addSql('COMMENT ON COLUMN time_entry.project_id IS \'(DC2Type:uuid)\'');
  32.         $this->addSql('ALTER TABLE time_entry ADD CONSTRAINT FK_6E537C0CA76ED395 FOREIGN KEY (user_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  33.         $this->addSql('ALTER TABLE time_entry ADD CONSTRAINT FK_6E537C0C166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         // this down() migration is auto-generated, please modify it to your needs
  38.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  39.         $this->addSql('DROP TABLE time_entry');
  40.     }
  41. }