migrations/Version20201103130531.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 Version20201103130531 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'add tables: developer_rate, month, plan';
  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 developer_rate (id UUID NOT NULL, project_id UUID DEFAULT NULL, developer_id UUID DEFAULT NULL, inner_rate INT NOT NULL, outer_rate INT NOT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('CREATE INDEX IDX_823C427A166D1F9C ON developer_rate (project_id)');
  20.         $this->addSql('CREATE INDEX IDX_823C427A64DD9267 ON developer_rate (developer_id)');
  21.         $this->addSql('COMMENT ON COLUMN developer_rate.id IS \'(DC2Type:uuid)\'');
  22.         $this->addSql('COMMENT ON COLUMN developer_rate.project_id IS \'(DC2Type:uuid)\'');
  23.         $this->addSql('COMMENT ON COLUMN developer_rate.developer_id IS \'(DC2Type:uuid)\'');
  24.         $this->addSql('CREATE TABLE month (id UUID NOT NULL, project_id UUID DEFAULT NULL, number INT NOT NULL, confirmed INT DEFAULT 0 NOT NULL, reminder INT DEFAULT 0 NOT NULL, PRIMARY KEY(id))');
  25.         $this->addSql('CREATE INDEX IDX_8EB61006166D1F9C ON month (project_id)');
  26.         $this->addSql('COMMENT ON COLUMN month.id IS \'(DC2Type:uuid)\'');
  27.         $this->addSql('COMMENT ON COLUMN month.project_id IS \'(DC2Type:uuid)\'');
  28.         $this->addSql('CREATE TABLE plan (id UUID NOT NULL, month_id UUID DEFAULT NULL, developer_id UUID DEFAULT NULL, developer_rate_id UUID DEFAULT NULL, project_id UUID DEFAULT NULL, date_start DATE NOT NULL, date_end DATE NOT NULL, expected_incoming INT DEFAULT NULL, work_hours INT DEFAULT 0 NOT NULL, PRIMARY KEY(id))');
  29.         $this->addSql('CREATE INDEX IDX_DD5A5B7DA0CBDE4 ON plan (month_id)');
  30.         $this->addSql('CREATE INDEX IDX_DD5A5B7D64DD9267 ON plan (developer_id)');
  31.         $this->addSql('CREATE INDEX IDX_DD5A5B7DD2077934 ON plan (developer_rate_id)');
  32.         $this->addSql('CREATE INDEX IDX_DD5A5B7D166D1F9C ON plan (project_id)');
  33.         $this->addSql('COMMENT ON COLUMN plan.id IS \'(DC2Type:uuid)\'');
  34.         $this->addSql('COMMENT ON COLUMN plan.month_id IS \'(DC2Type:uuid)\'');
  35.         $this->addSql('COMMENT ON COLUMN plan.developer_id IS \'(DC2Type:uuid)\'');
  36.         $this->addSql('COMMENT ON COLUMN plan.developer_rate_id IS \'(DC2Type:uuid)\'');
  37.         $this->addSql('COMMENT ON COLUMN plan.project_id IS \'(DC2Type:uuid)\'');
  38.         $this->addSql('COMMENT ON COLUMN plan.date_start IS \'(DC2Type:date_immutable)\'');
  39.         $this->addSql('COMMENT ON COLUMN plan.date_end IS \'(DC2Type:date_immutable)\'');
  40.         $this->addSql('ALTER TABLE developer_rate ADD CONSTRAINT FK_823C427A166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('ALTER TABLE developer_rate ADD CONSTRAINT FK_823C427A64DD9267 FOREIGN KEY (developer_id) REFERENCES developer (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  42.         $this->addSql('ALTER TABLE month ADD CONSTRAINT FK_8EB61006166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  43.         $this->addSql('ALTER TABLE plan ADD CONSTRAINT FK_DD5A5B7DA0CBDE4 FOREIGN KEY (month_id) REFERENCES month (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  44.         $this->addSql('ALTER TABLE plan ADD CONSTRAINT FK_DD5A5B7D64DD9267 FOREIGN KEY (developer_id) REFERENCES developer (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  45.         $this->addSql('ALTER TABLE plan ADD CONSTRAINT FK_DD5A5B7DD2077934 FOREIGN KEY (developer_rate_id) REFERENCES developer_rate (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  46.         $this->addSql('ALTER TABLE plan ADD CONSTRAINT FK_DD5A5B7D166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  47.         $this->addSql('DROP TABLE developers_rate');
  48.     }
  49.     public function down(Schema $schema): void
  50.     {
  51.         // this down() migration is auto-generated, please modify it to your needs
  52.         $this->addSql('ALTER TABLE plan DROP CONSTRAINT FK_DD5A5B7DD2077934');
  53.         $this->addSql('ALTER TABLE plan DROP CONSTRAINT FK_DD5A5B7DA0CBDE4');
  54.         $this->addSql('CREATE TABLE developers_rate (id UUID NOT NULL, project_id UUID DEFAULT NULL, developer_id UUID DEFAULT NULL, inner_rate INT NOT NULL, outer_rate INT NOT NULL, PRIMARY KEY(id))');
  55.         $this->addSql('CREATE INDEX idx_1d2f4a3864dd9267 ON developers_rate (developer_id)');
  56.         $this->addSql('CREATE INDEX idx_1d2f4a38166d1f9c ON developers_rate (project_id)');
  57.         $this->addSql('COMMENT ON COLUMN developers_rate.id IS \'(DC2Type:uuid)\'');
  58.         $this->addSql('COMMENT ON COLUMN developers_rate.project_id IS \'(DC2Type:uuid)\'');
  59.         $this->addSql('COMMENT ON COLUMN developers_rate.developer_id IS \'(DC2Type:uuid)\'');
  60.         $this->addSql('ALTER TABLE developers_rate ADD CONSTRAINT fk_1d2f4a38166d1f9c FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  61.         $this->addSql('ALTER TABLE developers_rate ADD CONSTRAINT fk_1d2f4a3864dd9267 FOREIGN KEY (developer_id) REFERENCES developer (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  62.         $this->addSql('DROP TABLE developer_rate');
  63.         $this->addSql('DROP TABLE month');
  64.         $this->addSql('DROP TABLE plan');
  65.     }
  66. }