FestinHegre/migrations/Version20241017133242.php

50 lines
2.9 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 Version20241017133242 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 SEQUENCE plats_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE reductions_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE plats (id INT NOT NULL, reduction_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, prix DOUBLE PRECISION NOT NULL, categorie VARCHAR(255) NOT NULL, statut BOOLEAN NOT NULL, nb_de_commande INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_854A620AC03CB092 ON plats (reduction_id)');
$this->addSql('CREATE TABLE plats_commandes (plats_id INT NOT NULL, commandes_id INT NOT NULL, PRIMARY KEY(plats_id, commandes_id))');
$this->addSql('CREATE INDEX IDX_7F8CABAAAA14E1C8 ON plats_commandes (plats_id)');
$this->addSql('CREATE INDEX IDX_7F8CABAA8BF5C2E6 ON plats_commandes (commandes_id)');
$this->addSql('CREATE TABLE reductions (id INT NOT NULL, description VARCHAR(255) NOT NULL, prix DOUBLE PRECISION NOT NULL, pourcentage INT NOT NULL, montant_fixe VARCHAR(255) NOT NULL, date_debut TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, date_fin TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE plats ADD CONSTRAINT FK_854A620AC03CB092 FOREIGN KEY (reduction_id) REFERENCES reductions (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE plats_commandes ADD CONSTRAINT FK_7F8CABAAAA14E1C8 FOREIGN KEY (plats_id) REFERENCES plats (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE plats_commandes ADD CONSTRAINT FK_7F8CABAA8BF5C2E6 FOREIGN KEY (commandes_id) REFERENCES commandes (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE plats_id_seq CASCADE');
$this->addSql('DROP SEQUENCE reductions_id_seq CASCADE');
$this->addSql('ALTER TABLE plats DROP CONSTRAINT FK_854A620AC03CB092');
$this->addSql('ALTER TABLE plats_commandes DROP CONSTRAINT FK_7F8CABAAAA14E1C8');
$this->addSql('ALTER TABLE plats_commandes DROP CONSTRAINT FK_7F8CABAA8BF5C2E6');
$this->addSql('DROP TABLE plats');
$this->addSql('DROP TABLE plats_commandes');
$this->addSql('DROP TABLE reductions');
}
}