migrations/Version20230711125223.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 Version20230711125223 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE quote_quote (id UUID NOT NULL, topic_id UUID DEFAULT NULL, name TEXT NOT NULL, author VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('CREATE INDEX IDX_668E46951F55203D ON quote_quote (topic_id)');
  20.         $this->addSql('COMMENT ON COLUMN quote_quote.id IS \'(DC2Type:quote_quote_id)\'');
  21.         $this->addSql('COMMENT ON COLUMN quote_quote.topic_id IS \'(DC2Type:quote_topic_id)\'');
  22.         $this->addSql('CREATE TABLE quote_topic (id UUID NOT NULL, name VARCHAR(255) NOT NULL, sort INT NOT NULL, PRIMARY KEY(id))');
  23.         $this->addSql('COMMENT ON COLUMN quote_topic.id IS \'(DC2Type:quote_topic_id)\'');
  24.         $this->addSql('CREATE TABLE user_users (id UUID NOT NULL, topic_id UUID DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, surname VARCHAR(255) DEFAULT NULL, gender VARCHAR(16) DEFAULT NULL, email VARCHAR(255) NOT NULL, password_hash VARCHAR(255) DEFAULT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, role VARCHAR(16) NOT NULL, PRIMARY KEY(id))');
  25.         $this->addSql('CREATE INDEX IDX_F6415EB11F55203D ON user_users (topic_id)');
  26.         $this->addSql('COMMENT ON COLUMN user_users.id IS \'(DC2Type:user_user_id)\'');
  27.         $this->addSql('COMMENT ON COLUMN user_users.topic_id IS \'(DC2Type:quote_topic_id)\'');
  28.         $this->addSql('COMMENT ON COLUMN user_users.date IS \'(DC2Type:datetime_immutable)\'');
  29.         $this->addSql('COMMENT ON COLUMN user_users.role IS \'(DC2Type:user_user_role)\'');
  30.         $this->addSql('ALTER TABLE quote_quote ADD CONSTRAINT FK_668E46951F55203D FOREIGN KEY (topic_id) REFERENCES quote_topic (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  31.         $this->addSql('ALTER TABLE user_users ADD CONSTRAINT FK_F6415EB11F55203D FOREIGN KEY (topic_id) REFERENCES quote_topic (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.         $this->addSql('CREATE SCHEMA public');
  37.         $this->addSql('ALTER TABLE quote_quote DROP CONSTRAINT FK_668E46951F55203D');
  38.         $this->addSql('ALTER TABLE user_users DROP CONSTRAINT FK_F6415EB11F55203D');
  39.         $this->addSql('DROP TABLE quote_quote');
  40.         $this->addSql('DROP TABLE quote_topic');
  41.         $this->addSql('DROP TABLE user_users');
  42.     }
  43. }