-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersion20220430202304.php
47 lines (41 loc) · 3 KB
/
Version20220430202304.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?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 Version20220430202304 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 country (id INT AUTO_INCREMENT NOT NULL, locale_id INT NOT NULL, title VARCHAR(255) NOT NULL, INDEX IDX_5373C966E559DFD1 (locale_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE locale (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, code VARCHAR(3) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, price DOUBLE PRECISION NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product_vat (product_id INT NOT NULL, vat_id INT NOT NULL, INDEX IDX_649C762C4584665A (product_id), INDEX IDX_649C762CB5B63A6B (vat_id), PRIMARY KEY(product_id, vat_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE vat (id INT AUTO_INCREMENT NOT NULL, country_id INT NOT NULL, rate DOUBLE PRECISION NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_84B32233F92F3E70 (country_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE country ADD CONSTRAINT FK_5373C966E559DFD1 FOREIGN KEY (locale_id) REFERENCES locale (id)');
$this->addSql('ALTER TABLE product_vat ADD CONSTRAINT FK_649C762C4584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product_vat ADD CONSTRAINT FK_649C762CB5B63A6B FOREIGN KEY (vat_id) REFERENCES vat (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE vat ADD CONSTRAINT FK_84B32233F92F3E70 FOREIGN KEY (country_id) REFERENCES country (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE vat DROP FOREIGN KEY FK_84B32233F92F3E70');
$this->addSql('ALTER TABLE country DROP FOREIGN KEY FK_5373C966E559DFD1');
$this->addSql('ALTER TABLE product_vat DROP FOREIGN KEY FK_649C762C4584665A');
$this->addSql('ALTER TABLE product_vat DROP FOREIGN KEY FK_649C762CB5B63A6B');
$this->addSql('DROP TABLE country');
$this->addSql('DROP TABLE locale');
$this->addSql('DROP TABLE product');
$this->addSql('DROP TABLE product_vat');
$this->addSql('DROP TABLE vat');
}
}