68 lines
6.4 KiB
PHP
68 lines
6.4 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 Version20240716105848 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 Expense_config (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, delay INT DEFAULT NULL, enabled TINYINT(1) DEFAULT NULL, amount INT NOT NULL, repeatitions INT DEFAULT NULL, INDEX IDX_4797F5B27E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE festival (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, fond_de_caisse_avant INT NOT NULL, fond_de_caisse_apres INT NOT NULL, chiffre_affaire INT NOT NULL, frais_inscription INT DEFAULT NULL, frais_hebergement INT DEFAULT NULL, frais_transport INT DEFAULT NULL, frais_repas INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, product_category_id INT DEFAULT NULL, stock_count INT NOT NULL, name VARCHAR(255) NOT NULL, image VARCHAR(255) DEFAULT NULL, INDEX IDX_D34A04AD7E3C61F9 (owner_id), INDEX IDX_D34A04ADBE6903FD (product_category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE product_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE product_category_user (product_category_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_DCE5B0FCBE6903FD (product_category_id), INDEX IDX_DCE5B0FCA76ED395 (user_id), PRIMARY KEY(product_category_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE product_sold (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, image VARCHAR(255) DEFAULT NULL, INDEX IDX_153AFF387E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE sell_record (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, festival_id INT DEFAULT NULL, customer_gender VARCHAR(255) DEFAULT NULL, date DATE NOT NULL, amount INT NOT NULL, paid_by_customer INT DEFAULT NULL, INDEX IDX_F9F12A027E3C61F9 (owner_id), INDEX IDX_F9F12A028AEBAF57 (festival_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE serie_festival (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, date_creation DATE NOT NULL, INDEX IDX_4DFA58B17E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
$this->addSql('ALTER TABLE Expense_config ADD CONSTRAINT FK_4797F5B27E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
|
|
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD7E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
|
|
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADBE6903FD FOREIGN KEY (product_category_id) REFERENCES product_category (id)');
|
|
$this->addSql('ALTER TABLE product_category_user ADD CONSTRAINT FK_DCE5B0FCBE6903FD FOREIGN KEY (product_category_id) REFERENCES product_category (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE product_category_user ADD CONSTRAINT FK_DCE5B0FCA76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE product_sold ADD CONSTRAINT FK_153AFF387E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
|
|
$this->addSql('ALTER TABLE sell_record ADD CONSTRAINT FK_F9F12A027E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
|
|
$this->addSql('ALTER TABLE sell_record ADD CONSTRAINT FK_F9F12A028AEBAF57 FOREIGN KEY (festival_id) REFERENCES festival (id)');
|
|
$this->addSql('ALTER TABLE serie_festival ADD CONSTRAINT FK_4DFA58B17E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
|
|
$this->addSql('DROP TABLE `admin`');
|
|
$this->addSql('DROP TABLE user_account');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE TABLE `admin` (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, email VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
|
$this->addSql('CREATE TABLE user_account (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
|
$this->addSql('ALTER TABLE Expense_config DROP FOREIGN KEY FK_4797F5B27E3C61F9');
|
|
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD7E3C61F9');
|
|
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADBE6903FD');
|
|
$this->addSql('ALTER TABLE product_category_user DROP FOREIGN KEY FK_DCE5B0FCBE6903FD');
|
|
$this->addSql('ALTER TABLE product_category_user DROP FOREIGN KEY FK_DCE5B0FCA76ED395');
|
|
$this->addSql('ALTER TABLE product_sold DROP FOREIGN KEY FK_153AFF387E3C61F9');
|
|
$this->addSql('ALTER TABLE sell_record DROP FOREIGN KEY FK_F9F12A027E3C61F9');
|
|
$this->addSql('ALTER TABLE sell_record DROP FOREIGN KEY FK_F9F12A028AEBAF57');
|
|
$this->addSql('ALTER TABLE serie_festival DROP FOREIGN KEY FK_4DFA58B17E3C61F9');
|
|
$this->addSql('DROP TABLE Expense_config');
|
|
$this->addSql('DROP TABLE festival');
|
|
$this->addSql('DROP TABLE product');
|
|
$this->addSql('DROP TABLE product_category');
|
|
$this->addSql('DROP TABLE product_category_user');
|
|
$this->addSql('DROP TABLE product_sold');
|
|
$this->addSql('DROP TABLE sell_record');
|
|
$this->addSql('DROP TABLE serie_festival');
|
|
}
|
|
}
|