<?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 Version20220607140540 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 account (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, stripe_user_id VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE api_token (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expire_at DATETIME NOT NULL, INDEX IDX_7BA2F5EBA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE brand (id INT AUTO_INCREMENT NOT NULL, account_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, url VARCHAR(255) DEFAULT NULL, rooms INT DEFAULT NULL, INDEX IDX_1C52F9589B6B5FBA (account_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE brand_contact (brand_id INT NOT NULL, contact_id INT NOT NULL, INDEX IDX_AB59434344F5D008 (brand_id), INDEX IDX_AB594343E7A1254A (contact_id), PRIMARY KEY(brand_id, contact_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE card (id INT AUTO_INCREMENT NOT NULL, company_id INT DEFAULT NULL, stripe_id VARCHAR(255) NOT NULL, last_four VARCHAR(4) NOT NULL, exp_month INT NOT NULL, exp_year INT NOT NULL, brand VARCHAR(50) NOT NULL, fingerprint VARCHAR(255) NOT NULL, INDEX IDX_161498D3979B1AD6 (company_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE company (id INT AUTO_INCREMENT NOT NULL, account_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, address LONGTEXT NOT NULL, zip_code VARCHAR(25) NOT NULL, city VARCHAR(50) NOT NULL, country VARCHAR(50) NOT NULL, INDEX IDX_4FBF094F9B6B5FBA (account_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE company_contact (company_id INT NOT NULL, contact_id INT NOT NULL, INDEX IDX_6C30FCEF979B1AD6 (company_id), INDEX IDX_6C30FCEFE7A1254A (contact_id), PRIMARY KEY(company_id, contact_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, account_id INT DEFAULT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) DEFAULT NULL, role VARCHAR(255) NOT NULL, INDEX IDX_4C62E6389B6B5FBA (account_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE permission (id INT AUTO_INCREMENT NOT NULL, account_id INT DEFAULT NULL, user_id INT DEFAULT NULL, INDEX IDX_E04992AA9B6B5FBA (account_id), INDEX IDX_E04992AAA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE price (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, name VARCHAR(255) NOT NULL, stripe_price_id VARCHAR(255) NOT NULL, amount INT NOT NULL, currency VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, recurring TINYINT(1) NOT NULL, recurring_interval VARCHAR(255) DEFAULT NULL, active TINYINT(1) NOT NULL, tiers_mode VARCHAR(255) DEFAULT NULL, tiers LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', billing_scheme VARCHAR(255) NOT NULL, INDEX IDX_CAC822D94584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, stripe_product_id VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, trial_period INT DEFAULT NULL, active TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE subscription (id INT AUTO_INCREMENT NOT NULL, brand_id INT DEFAULT NULL, card_id INT DEFAULT NULL, stripe_sub_id VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, ended_at DATETIME DEFAULT NULL, current_period_start DATETIME NOT NULL, current_period_end DATETIME NOT NULL, INDEX IDX_A3C664D344F5D008 (brand_id), INDEX IDX_A3C664D34ACC9A20 (card_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE subscription_item (id INT AUTO_INCREMENT NOT NULL, price_id INT DEFAULT NULL, subscription_id INT DEFAULT NULL, stripe_item_id VARCHAR(255) NOT NULL, quantity INT NOT NULL, INDEX IDX_28273500D614C7E7 (price_id), INDEX IDX_282735009A1887DC (subscription_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE api_token ADD CONSTRAINT FK_7BA2F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE brand ADD CONSTRAINT FK_1C52F9589B6B5FBA FOREIGN KEY (account_id) REFERENCES account (id)');
$this->addSql('ALTER TABLE brand_contact ADD CONSTRAINT FK_AB59434344F5D008 FOREIGN KEY (brand_id) REFERENCES brand (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE brand_contact ADD CONSTRAINT FK_AB594343E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE card ADD CONSTRAINT FK_161498D3979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('ALTER TABLE company ADD CONSTRAINT FK_4FBF094F9B6B5FBA FOREIGN KEY (account_id) REFERENCES account (id)');
$this->addSql('ALTER TABLE company_contact ADD CONSTRAINT FK_6C30FCEF979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE company_contact ADD CONSTRAINT FK_6C30FCEFE7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6389B6B5FBA FOREIGN KEY (account_id) REFERENCES account (id)');
$this->addSql('ALTER TABLE permission ADD CONSTRAINT FK_E04992AA9B6B5FBA FOREIGN KEY (account_id) REFERENCES account (id)');
$this->addSql('ALTER TABLE permission ADD CONSTRAINT FK_E04992AAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE price ADD CONSTRAINT FK_CAC822D94584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE subscription ADD CONSTRAINT FK_A3C664D344F5D008 FOREIGN KEY (brand_id) REFERENCES brand (id)');
$this->addSql('ALTER TABLE subscription ADD CONSTRAINT FK_A3C664D34ACC9A20 FOREIGN KEY (card_id) REFERENCES card (id)');
$this->addSql('ALTER TABLE subscription_item ADD CONSTRAINT FK_28273500D614C7E7 FOREIGN KEY (price_id) REFERENCES price (id)');
$this->addSql('ALTER TABLE subscription_item ADD CONSTRAINT FK_282735009A1887DC FOREIGN KEY (subscription_id) REFERENCES subscription (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE brand DROP FOREIGN KEY FK_1C52F9589B6B5FBA');
$this->addSql('ALTER TABLE company DROP FOREIGN KEY FK_4FBF094F9B6B5FBA');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6389B6B5FBA');
$this->addSql('ALTER TABLE permission DROP FOREIGN KEY FK_E04992AA9B6B5FBA');
$this->addSql('ALTER TABLE brand_contact DROP FOREIGN KEY FK_AB59434344F5D008');
$this->addSql('ALTER TABLE subscription DROP FOREIGN KEY FK_A3C664D344F5D008');
$this->addSql('ALTER TABLE subscription DROP FOREIGN KEY FK_A3C664D34ACC9A20');
$this->addSql('ALTER TABLE card DROP FOREIGN KEY FK_161498D3979B1AD6');
$this->addSql('ALTER TABLE company_contact DROP FOREIGN KEY FK_6C30FCEF979B1AD6');
$this->addSql('ALTER TABLE brand_contact DROP FOREIGN KEY FK_AB594343E7A1254A');
$this->addSql('ALTER TABLE company_contact DROP FOREIGN KEY FK_6C30FCEFE7A1254A');
$this->addSql('ALTER TABLE subscription_item DROP FOREIGN KEY FK_28273500D614C7E7');
$this->addSql('ALTER TABLE price DROP FOREIGN KEY FK_CAC822D94584665A');
$this->addSql('ALTER TABLE subscription_item DROP FOREIGN KEY FK_282735009A1887DC');
$this->addSql('ALTER TABLE api_token DROP FOREIGN KEY FK_7BA2F5EBA76ED395');
$this->addSql('ALTER TABLE permission DROP FOREIGN KEY FK_E04992AAA76ED395');
$this->addSql('DROP TABLE account');
$this->addSql('DROP TABLE api_token');
$this->addSql('DROP TABLE brand');
$this->addSql('DROP TABLE brand_contact');
$this->addSql('DROP TABLE card');
$this->addSql('DROP TABLE company');
$this->addSql('DROP TABLE company_contact');
$this->addSql('DROP TABLE contact');
$this->addSql('DROP TABLE permission');
$this->addSql('DROP TABLE price');
$this->addSql('DROP TABLE product');
$this->addSql('DROP TABLE subscription');
$this->addSql('DROP TABLE subscription_item');
$this->addSql('DROP TABLE user');
}
}