migrations/Version20181103144042.php line 1

  1. <?php
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: added user of last change for user entity
  7.  */
  8. class Version20181103144042 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 users ADD users_id INT DEFAULT 1 NOT NULL');
  18.         $this->addSql('ALTER TABLE media ALTER users_id DROP DEFAULT');
  19.         $this->addSql('COMMENT ON COLUMN users.users_id IS \'Creating/editing user\'');
  20.         $this->addSql('ALTER TABLE users ADD CONSTRAINT fk_users_users FOREIGN KEY (users_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  21.         //$this->addSql('CREATE INDEX IDX_1483A5E967B3B43D ON users (users_id)');
  22.     }
  23.     /**
  24.      * @param Schema $schema
  25.      */
  26.     public function down(Schema $schema) : void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  30.         //$this->addSql('CREATE SCHEMA public');
  31.         $this->addSql('ALTER TABLE users DROP CONSTRAINT fk_users_users');
  32.         //$this->addSql('DROP INDEX IDX_1483A5E967B3B43D');
  33.         $this->addSql('ALTER TABLE users DROP users_id');
  34.     }
  35. }