migrations/Version20180102131934.php line 1

  1. <?php
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * set default value of columns created_at to now()
  7.  */
  8. class Version20180102131934 extends AbstractMigration
  9. {
  10.     /**
  11.      * @param Schema $schema
  12.      */
  13.     public function up(Schema $schema) : void
  14.     {
  15.         // this up() migration is auto-generated, please modify it to your needs
  16.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  17.         $this->addSql('ALTER TABLE media ALTER created_at SET DEFAULT CURRENT_TIMESTAMP ');
  18.         $this->addSql('ALTER TABLE node ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  19.         $this->addSql('ALTER TABLE player_sessionhist ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  20.         $this->addSql('ALTER TABLE users ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  21.         $this->addSql('ALTER TABLE mcq ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  22.         $this->addSql('ALTER TABLE link ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  23.         $this->addSql('ALTER TABLE scenario ALTER created_at SET DEFAULT CURRENT_TIMESTAMP');
  24.     }
  25.     /**
  26.      * @param Schema $schema
  27.      */
  28.     public function down(Schema $schema) : void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  32.         //$this->addSql('CREATE SCHEMA public');
  33.         $this->addSql('ALTER TABLE mcq ALTER created_at DROP DEFAULT');
  34.         $this->addSql('ALTER TABLE users ALTER created_at DROP DEFAULT');
  35.         $this->addSql('ALTER TABLE scenario ALTER created_at DROP DEFAULT');
  36.         $this->addSql('ALTER TABLE player_sessionhist ALTER created_at DROP DEFAULT');
  37.         $this->addSql('ALTER TABLE node ALTER created_at DROP DEFAULT');
  38.         $this->addSql('ALTER TABLE link ALTER created_at DROP DEFAULT');
  39.         $this->addSql('ALTER TABLE media ALTER created_at DROP DEFAULT');
  40.     }
  41. }