migrations/Version20210723134342.php line 1

  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 Version20210723134342 extends AbstractMigration
  10. {
  11. public function getDescription() : string
  12. {
  13. return '';
  14. }
  15. public function up(Schema $schema) : void
  16. {
  17. $this->addSql('CREATE TABLE residents (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, firstname VARCHAR(255) DEFAULT NULL, lastname VARCHAR(255) DEFAULT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, has_accepted_terms TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_F27069E4E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  18. $this->addSql('ALTER TABLE flat ADD resident_id INT DEFAULT NULL');
  19. $this->addSql('ALTER TABLE flat ADD CONSTRAINT FK_554AAA448012C5B0 FOREIGN KEY (resident_id) REFERENCES residents (id) ON DELETE SET NULL');
  20. $this->addSql('CREATE INDEX IDX_554AAA448012C5B0 ON flat (resident_id)');
  21. }
  22. public function down(Schema $schema) : void
  23. {
  24. $this->addSql('ALTER TABLE flat DROP FOREIGN KEY FK_554AAA448012C5B0');
  25. $this->addSql('DROP TABLE residents');
  26. $this->addSql('DROP INDEX IDX_554AAA448012C5B0 ON flat');
  27. $this->addSql('ALTER TABLE flat DROP resident_id');
  28. }
  29. }