|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace DoctrineMigrations; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Schema\Schema; |
| 8 | +use Doctrine\Migrations\AbstractMigration; |
| 9 | + |
| 10 | +/** |
| 11 | + * Auto-generated Migration: Please modify to your needs! |
| 12 | + */ |
| 13 | +final class Version20201230215549 extends AbstractMigration |
| 14 | +{ |
| 15 | + public function getDescription() : string |
| 16 | + { |
| 17 | + return ''; |
| 18 | + } |
| 19 | + |
| 20 | + public function up(Schema $schema) : void |
| 21 | + { |
| 22 | + // this up() migration is auto-generated, please modify it to your needs |
| 23 | + $this->addSql('CREATE TABLE consumer (id SERIAL NOT NULL, provider_id INT NOT NULL, given_name VARCHAR(100) DEFAULT NULL, family_name VARCHAR(100) DEFAULT NULL, email VARCHAR(100) NOT NULL, PRIMARY KEY(id))'); |
| 24 | + $this->addSql('CREATE INDEX IDX_705B3727A53A8AA ON consumer (provider_id)'); |
| 25 | + $this->addSql('CREATE TABLE customer (id SERIAL NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
| 26 | + $this->addSql('CREATE UNIQUE INDEX UNIQ_81398E09F85E0677 ON customer (username)'); |
| 27 | + $this->addSql('CREATE TABLE product (id SERIAL NOT NULL, name VARCHAR(100) NOT NULL, brand VARCHAR(100) NOT NULL, released_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, is_available BOOLEAN NOT NULL, PRIMARY KEY(id))'); |
| 28 | + $this->addSql('ALTER TABLE consumer ADD CONSTRAINT FK_705B3727A53A8AA FOREIGN KEY (provider_id) REFERENCES customer (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
| 29 | + } |
| 30 | + |
| 31 | + public function down(Schema $schema) : void |
| 32 | + { |
| 33 | + // this down() migration is auto-generated, please modify it to your needs |
| 34 | + $this->addSql('CREATE SCHEMA public'); |
| 35 | + $this->addSql('ALTER TABLE consumer DROP CONSTRAINT FK_705B3727A53A8AA'); |
| 36 | + $this->addSql('DROP TABLE consumer'); |
| 37 | + $this->addSql('DROP TABLE customer'); |
| 38 | + $this->addSql('DROP TABLE product'); |
| 39 | + } |
| 40 | +} |
0 commit comments