74 lines
4.8 KiB
PHP
74 lines
4.8 KiB
PHP
<?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 Version20250214100702 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 selling_product (selling_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_6F085AF0155A4545 (selling_id), INDEX IDX_6F085AF04584665A (product_id), PRIMARY KEY(selling_id, product_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('ALTER TABLE selling_product ADD CONSTRAINT FK_6F085AF0155A4545 FOREIGN KEY (selling_id) REFERENCES selling (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE selling_product ADD CONSTRAINT FK_6F085AF04584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE category ADD user_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C1A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
|
|
$this->addSql('CREATE INDEX IDX_64C19C1A76ED395 ON category (user_id)');
|
|
$this->addSql('ALTER TABLE expense ADD user_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE expense ADD CONSTRAINT FK_2D3A8DA6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
|
|
$this->addSql('CREATE INDEX IDX_2D3A8DA6A76ED395 ON expense (user_id)');
|
|
$this->addSql('ALTER TABLE festival ADD user_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE festival ADD CONSTRAINT FK_57CF789A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
|
|
$this->addSql('CREATE INDEX IDX_57CF789A76ED395 ON festival (user_id)');
|
|
$this->addSql('ALTER TABLE group_of_products ADD user_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE group_of_products ADD CONSTRAINT FK_2A99B370A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
|
|
$this->addSql('CREATE INDEX IDX_2A99B370A76ED395 ON group_of_products (user_id)');
|
|
$this->addSql('ALTER TABLE product ADD user_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
|
|
$this->addSql('CREATE INDEX IDX_D34A04ADA76ED395 ON product (user_id)');
|
|
$this->addSql('ALTER TABLE selling DROP products');
|
|
$this->addSql('ALTER TABLE user ADD current_festival_id INT DEFAULT NULL, DROP owner, DROP expenses, DROP current_festival');
|
|
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649343F048E FOREIGN KEY (current_festival_id) REFERENCES festival (id)');
|
|
$this->addSql('CREATE INDEX IDX_8D93D649343F048E ON user (current_festival_id)');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE selling_product DROP FOREIGN KEY FK_6F085AF0155A4545');
|
|
$this->addSql('ALTER TABLE selling_product DROP FOREIGN KEY FK_6F085AF04584665A');
|
|
$this->addSql('DROP TABLE selling_product');
|
|
$this->addSql('ALTER TABLE expense DROP FOREIGN KEY FK_2D3A8DA6A76ED395');
|
|
$this->addSql('DROP INDEX IDX_2D3A8DA6A76ED395 ON expense');
|
|
$this->addSql('ALTER TABLE expense DROP user_id');
|
|
$this->addSql('ALTER TABLE festival DROP FOREIGN KEY FK_57CF789A76ED395');
|
|
$this->addSql('DROP INDEX IDX_57CF789A76ED395 ON festival');
|
|
$this->addSql('ALTER TABLE festival DROP user_id');
|
|
$this->addSql('ALTER TABLE selling ADD products LONGTEXT NOT NULL COMMENT \'(DC2Type:object)\'');
|
|
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADA76ED395');
|
|
$this->addSql('DROP INDEX IDX_D34A04ADA76ED395 ON product');
|
|
$this->addSql('ALTER TABLE product DROP user_id');
|
|
$this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C1A76ED395');
|
|
$this->addSql('DROP INDEX IDX_64C19C1A76ED395 ON category');
|
|
$this->addSql('ALTER TABLE category DROP user_id');
|
|
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649343F048E');
|
|
$this->addSql('DROP INDEX IDX_8D93D649343F048E ON user');
|
|
$this->addSql('ALTER TABLE user ADD owner LONGTEXT NOT NULL COMMENT \'(DC2Type:object)\', ADD expenses LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:object)\', ADD current_festival LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:object)\', DROP current_festival_id');
|
|
$this->addSql('ALTER TABLE group_of_products DROP FOREIGN KEY FK_2A99B370A76ED395');
|
|
$this->addSql('DROP INDEX IDX_2A99B370A76ED395 ON group_of_products');
|
|
$this->addSql('ALTER TABLE group_of_products DROP user_id');
|
|
}
|
|
}
|