73 lines
5.3 KiB
PHP
73 lines
5.3 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 Version20240626175246 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 menu_item (id BLOB NOT NULL, name VARCHAR(255) NOT NULL, food_vendor_id BLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_D754D5506EF983E8 FOREIGN KEY (food_vendor_id) REFERENCES food_vendor (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
|
$this->addSql('CREATE INDEX IDX_D754D5506EF983E8 ON menu_item (food_vendor_id)');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__food_order AS SELECT id, food_vendor_id, closed_at FROM food_order');
|
|
$this->addSql('DROP TABLE food_order');
|
|
$this->addSql('CREATE TABLE food_order (id BLOB NOT NULL, food_vendor_id BLOB NOT NULL, closed_at DATETIME DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_44856726EF983E8 FOREIGN KEY (food_vendor_id) REFERENCES food_vendor (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
|
$this->addSql('INSERT INTO food_order (id, food_vendor_id, closed_at) SELECT id, food_vendor_id, closed_at FROM __temp__food_order');
|
|
$this->addSql('DROP TABLE __temp__food_order');
|
|
$this->addSql('CREATE INDEX IDX_44856726EF983E8 ON food_order (food_vendor_id)');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__food_vendor AS SELECT id, name FROM food_vendor');
|
|
$this->addSql('DROP TABLE food_vendor');
|
|
$this->addSql('CREATE TABLE food_vendor (id BLOB NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('INSERT INTO food_vendor (id, name) SELECT id, name FROM __temp__food_vendor');
|
|
$this->addSql('DROP TABLE __temp__food_vendor');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__order_item AS SELECT id, food_order_id, name, extras FROM order_item');
|
|
$this->addSql('DROP TABLE order_item');
|
|
$this->addSql('CREATE TABLE order_item (id BLOB NOT NULL, food_order_id BLOB DEFAULT NULL, name VARCHAR(255) NOT NULL, extras VARCHAR(255) DEFAULT NULL, menu_item_id BLOB DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_52EA1F09A5D24A7A FOREIGN KEY (food_order_id) REFERENCES food_order (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_52EA1F099AB44FE0 FOREIGN KEY (menu_item_id) REFERENCES menu_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
|
$this->addSql('INSERT INTO order_item (id, food_order_id, name, extras) SELECT id, food_order_id, name, extras FROM __temp__order_item');
|
|
$this->addSql('DROP TABLE __temp__order_item');
|
|
$this->addSql('CREATE INDEX IDX_52EA1F09A5D24A7A ON order_item (food_order_id)');
|
|
$this->addSql('CREATE INDEX IDX_52EA1F099AB44FE0 ON order_item (menu_item_id)');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('DROP TABLE menu_item');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__food_order AS SELECT id, closed_at, food_vendor_id FROM food_order');
|
|
$this->addSql('DROP TABLE food_order');
|
|
$this->addSql('CREATE TABLE food_order (id BLOB NOT NULL --(DC2Type:ulid)
|
|
, closed_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable)
|
|
, food_vendor_id BLOB NOT NULL --(DC2Type:ulid)
|
|
, PRIMARY KEY(id), CONSTRAINT FK_44856726EF983E8 FOREIGN KEY (food_vendor_id) REFERENCES food_vendor (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
|
$this->addSql('INSERT INTO food_order (id, closed_at, food_vendor_id) SELECT id, closed_at, food_vendor_id FROM __temp__food_order');
|
|
$this->addSql('DROP TABLE __temp__food_order');
|
|
$this->addSql('CREATE INDEX IDX_44856726EF983E8 ON food_order (food_vendor_id)');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__food_vendor AS SELECT id, name FROM food_vendor');
|
|
$this->addSql('DROP TABLE food_vendor');
|
|
$this->addSql('CREATE TABLE food_vendor (id BLOB NOT NULL --(DC2Type:ulid)
|
|
, name VARCHAR(50) NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('INSERT INTO food_vendor (id, name) SELECT id, name FROM __temp__food_vendor');
|
|
$this->addSql('DROP TABLE __temp__food_vendor');
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__order_item AS SELECT id, name, extras, food_order_id FROM order_item');
|
|
$this->addSql('DROP TABLE order_item');
|
|
$this->addSql('CREATE TABLE order_item (id BLOB NOT NULL --(DC2Type:ulid)
|
|
, name VARCHAR(255) NOT NULL, extras VARCHAR(255) DEFAULT NULL, food_order_id BLOB NOT NULL --(DC2Type:ulid)
|
|
, PRIMARY KEY(id), CONSTRAINT FK_52EA1F09A5D24A7A FOREIGN KEY (food_order_id) REFERENCES food_order (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
|
$this->addSql('INSERT INTO order_item (id, name, extras, food_order_id) SELECT id, name, extras, food_order_id FROM __temp__order_item');
|
|
$this->addSql('DROP TABLE __temp__order_item');
|
|
$this->addSql('CREATE INDEX IDX_52EA1F09A5D24A7A ON order_item (food_order_id)');
|
|
}
|
|
}
|