migrations/Version20221227211506.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 Version20221227211506 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 billing (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', owner_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', plan_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', storage_plan_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', stripe_customer_id VARCHAR(255) DEFAULT NULL, stripe_storage_id VARCHAR(255) DEFAULT NULL, stripe_card_id VARCHAR(255) DEFAULT NULL, stripe_card_brand VARCHAR(255) DEFAULT NULL, stripe_card_exp_month INT DEFAULT NULL, stripe_card_exp_year INT DEFAULT NULL, stripe_card_last4 VARCHAR(255) DEFAULT NULL, stripe_card_name VARCHAR(255) DEFAULT NULL, stripe_card_address1 VARCHAR(255) DEFAULT NULL, stripe_card_address2 VARCHAR(255) DEFAULT NULL, stripe_card_city VARCHAR(255) DEFAULT NULL, stripe_card_state VARCHAR(255) DEFAULT NULL, stripe_card_zip VARCHAR(255) DEFAULT NULL, stripe_card_country VARCHAR(255) DEFAULT NULL, billing_cycle VARCHAR(255) DEFAULT NULL, next_payment NUMERIC(10, 2) DEFAULT NULL, seats INT DEFAULT NULL, storage_quantity INT DEFAULT NULL, storage_usage BIGINT DEFAULT NULL, expires_at DATETIME DEFAULT NULL, canceled_at DATETIME DEFAULT NULL, stripe_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_EC224CAA708DC647 (stripe_customer_id), UNIQUE INDEX UNIQ_EC224CAA27CB7D18 (stripe_storage_id), UNIQUE INDEX UNIQ_EC224CAA3F1B1098 (stripe_id), UNIQUE INDEX UNIQ_EC224CAA7E3C61F9 (owner_id), INDEX IDX_EC224CAAE899029B (plan_id), INDEX IDX_EC224CAA9FA531F9 (storage_plan_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE invoice (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', owner_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', card_brand VARCHAR(255) DEFAULT NULL, card_last4 VARCHAR(255) DEFAULT NULL, amount NUMERIC(10, 2) NOT NULL, paid TINYINT(1) NOT NULL, stripe_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_906517443F1B1098 (stripe_id), INDEX IDX_906517447E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE plan (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', amount NUMERIC(10, 2) NOT NULL, currency VARCHAR(255) NOT NULL, interval_name VARCHAR(255) NOT NULL, interval_count INT NOT NULL, livemode TINYINT(1) NOT NULL, trial_period_days INT DEFAULT NULL, metadata LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', name VARCHAR(255) NOT NULL, stripe_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_DD5A5B7D3F1B1098 (stripe_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAA7E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAAE899029B FOREIGN KEY (plan_id) REFERENCES plan (id) ON DELETE SET NULL');
  23.         $this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAA9FA531F9 FOREIGN KEY (storage_plan_id) REFERENCES plan (id) ON DELETE SET NULL');
  24.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_906517447E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE user ADD billing_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  26.         $this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6493B025C87 FOREIGN KEY (billing_id) REFERENCES billing (id) ON DELETE SET NULL');
  27.         $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D6493B025C87 ON user (billing_id)');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         // this down() migration is auto-generated, please modify it to your needs
  32.         $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6493B025C87');
  33.         $this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAA7E3C61F9');
  34.         $this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAAE899029B');
  35.         $this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAA9FA531F9');
  36.         $this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_906517447E3C61F9');
  37.         $this->addSql('DROP TABLE billing');
  38.         $this->addSql('DROP TABLE invoice');
  39.         $this->addSql('DROP TABLE plan');
  40.         $this->addSql('DROP INDEX UNIQ_8D93D6493B025C87 ON user');
  41.         $this->addSql('ALTER TABLE user DROP billing_id');
  42.     }
  43. }