<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221227211506 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$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');
$this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAA7E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAAE899029B FOREIGN KEY (plan_id) REFERENCES plan (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE billing ADD CONSTRAINT FK_EC224CAA9FA531F9 FOREIGN KEY (storage_plan_id) REFERENCES plan (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_906517447E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user ADD billing_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6493B025C87 FOREIGN KEY (billing_id) REFERENCES billing (id) ON DELETE SET NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D6493B025C87 ON user (billing_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6493B025C87');
$this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAA7E3C61F9');
$this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAAE899029B');
$this->addSql('ALTER TABLE billing DROP FOREIGN KEY FK_EC224CAA9FA531F9');
$this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_906517447E3C61F9');
$this->addSql('DROP TABLE billing');
$this->addSql('DROP TABLE invoice');
$this->addSql('DROP TABLE plan');
$this->addSql('DROP INDEX UNIQ_8D93D6493B025C87 ON user');
$this->addSql('ALTER TABLE user DROP billing_id');
}
}