92 lines
4.1 KiB
PHP
92 lines
4.1 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 Version20250609175837 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(<<<'SQL'
|
|
CREATE TABLE drink_type (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, updated_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, name VARCHAR(255) NOT NULL, description CLOB DEFAULT NULL, desired_stock INTEGER NOT NULL)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE UNIQUE INDEX UNIQ_841484B15E237E06 ON drink_type (name)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE inventory_record (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, drink_type_id INTEGER NOT NULL, quantity INTEGER NOT NULL, timestamp DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, updated_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, CONSTRAINT FK_9BE8033AE7E8D8A1 FOREIGN KEY (drink_type_id) REFERENCES drink_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_9BE8033AE7E8D8A1 ON inventory_record (drink_type_id)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE "order" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, updated_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, status VARCHAR(255) DEFAULT 'new' NOT NULL)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE order_item (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, drink_type_id INTEGER NOT NULL, order_id INTEGER NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, updated_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, quantity INTEGER NOT NULL, CONSTRAINT FK_52EA1F09E7E8D8A1 FOREIGN KEY (drink_type_id) REFERENCES drink_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_52EA1F098D9F6D38 FOREIGN KEY (order_id) REFERENCES "order" (id) NOT DEFERRABLE INITIALLY IMMEDIATE)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_52EA1F09E7E8D8A1 ON order_item (drink_type_id)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_52EA1F098D9F6D38 ON order_item (order_id)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE property_change_log (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, property_name VARCHAR(255) NOT NULL, entity_class VARCHAR(255) NOT NULL, entity_id INTEGER DEFAULT NULL, new_value VARCHAR(255) NOT NULL, change_date DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE system_config (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, updated_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
|
, "key" VARCHAR(255) NOT NULL, value CLOB NOT NULL)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE UNIQUE INDEX UNIQ_C4049ABD8A90ABA9 ON system_config ("key")
|
|
SQL);
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE drink_type
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE inventory_record
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE "order"
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE order_item
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE property_change_log
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
DROP TABLE system_config
|
|
SQL);
|
|
}
|
|
}
|