migrations/Version20220919085524.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 Version20220919085524 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 budget_category (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_D18348657E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE budget_expense (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, owner_id INT NOT NULL, creation_date DATETIME NOT NULL, info LONGTEXT NOT NULL, value NUMERIC(7, 2) NOT NULL, year INT NOT NULL, month INT NOT NULL, INDEX IDX_EFB9C74712469DE2 (category_id), INDEX IDX_EFB9C7477E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE budget_income (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, owner_id INT NOT NULL, creation_date DATETIME NOT NULL, info LONGTEXT NOT NULL, value NUMERIC(7, 2) NOT NULL, year INT NOT NULL, month INT NOT NULL, INDEX IDX_6B1D246C12469DE2 (category_id), INDEX IDX_6B1D246C7E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE budget_recurrent_expense (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, owner_id INT NOT NULL, value NUMERIC(7, 2) NOT NULL, info VARCHAR(255) NOT NULL, yearly TINYINT(1) NOT NULL, monthly TINYINT(1) NOT NULL, INDEX IDX_7F31171112469DE2 (category_id), INDEX IDX_7F3117117E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE budget_recurrent_income (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, owner_id INT NOT NULL, value NUMERIC(7, 2) NOT NULL, info VARCHAR(255) NOT NULL, yearly TINYINT(1) NOT NULL, monthly TINYINT(1) NOT NULL, INDEX IDX_5CD0E36312469DE2 (category_id), INDEX IDX_5CD0E3637E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE budget_category ADD CONSTRAINT FK_D18348657E3C61F9 FOREIGN KEY (owner_id) REFERENCES access (id)');
  24.         $this->addSql('ALTER TABLE budget_expense ADD CONSTRAINT FK_EFB9C74712469DE2 FOREIGN KEY (category_id) REFERENCES budget_category (id)');
  25.         $this->addSql('ALTER TABLE budget_expense ADD CONSTRAINT FK_EFB9C7477E3C61F9 FOREIGN KEY (owner_id) REFERENCES access (id)');
  26.         $this->addSql('ALTER TABLE budget_income ADD CONSTRAINT FK_6B1D246C12469DE2 FOREIGN KEY (category_id) REFERENCES budget_category (id)');
  27.         $this->addSql('ALTER TABLE budget_income ADD CONSTRAINT FK_6B1D246C7E3C61F9 FOREIGN KEY (owner_id) REFERENCES access (id)');
  28.         $this->addSql('ALTER TABLE budget_recurrent_expense ADD CONSTRAINT FK_7F31171112469DE2 FOREIGN KEY (category_id) REFERENCES budget_category (id)');
  29.         $this->addSql('ALTER TABLE budget_recurrent_expense ADD CONSTRAINT FK_7F3117117E3C61F9 FOREIGN KEY (owner_id) REFERENCES access (id)');
  30.         $this->addSql('ALTER TABLE budget_recurrent_income ADD CONSTRAINT FK_5CD0E36312469DE2 FOREIGN KEY (category_id) REFERENCES budget_category (id)');
  31.         $this->addSql('ALTER TABLE budget_recurrent_income ADD CONSTRAINT FK_5CD0E3637E3C61F9 FOREIGN KEY (owner_id) REFERENCES access (id)');
  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('ALTER TABLE budget_expense DROP FOREIGN KEY FK_EFB9C74712469DE2');
  37.         $this->addSql('ALTER TABLE budget_income DROP FOREIGN KEY FK_6B1D246C12469DE2');
  38.         $this->addSql('ALTER TABLE budget_recurrent_expense DROP FOREIGN KEY FK_7F31171112469DE2');
  39.         $this->addSql('ALTER TABLE budget_recurrent_income DROP FOREIGN KEY FK_5CD0E36312469DE2');
  40.         $this->addSql('DROP TABLE budget_category');
  41.         $this->addSql('DROP TABLE budget_expense');
  42.         $this->addSql('DROP TABLE budget_income');
  43.         $this->addSql('DROP TABLE budget_recurrent_expense');
  44.         $this->addSql('DROP TABLE budget_recurrent_income');
  45.     }
  46. }