You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 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 Version20250525132541 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 input_recipe_material (id INT AUTO_INCREMENT NOT NULL, recipe_id INT NOT NULL, material_id INT NOT NULL, consumed_quantity INT NOT NULL, INDEX IDX_77575DA759D8A214 (recipe_id), INDEX IDX_77575DA7E308AC6F (material_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE machine (id INT AUTO_INCREMENT NOT NULL, label_extra_info1 VARCHAR(255) DEFAULT NULL, label_extra_info2 VARCHAR(255) DEFAULT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE material (id INT AUTO_INCREMENT NOT NULL, type_id INT NOT NULL, is_craftable_by_default TINYINT(1) NOT NULL, name VARCHAR(50) NOT NULL, INDEX IDX_7CBE7595C54C8C93 (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE material_type (id INT AUTO_INCREMENT NOT NULL, stack_size INT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE output_recipe_material (id INT AUTO_INCREMENT NOT NULL, recipe_id INT NOT NULL, material_id INT NOT NULL, produced_quantity DOUBLE PRECISION NOT NULL, INDEX IDX_CB0D94B259D8A214 (recipe_id), INDEX IDX_CB0D94B2E308AC6F (material_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE recipe (id INT AUTO_INCREMENT NOT NULL, machine_id INT NOT NULL, crafting_time DOUBLE PRECISION NOT NULL, name VARCHAR(50) NOT NULL, INDEX IDX_DA88B137F6B75B26 (machine_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE input_recipe_material ADD CONSTRAINT FK_77575DA759D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id) ON DELETE CASCADE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE input_recipe_material ADD CONSTRAINT FK_77575DA7E308AC6F FOREIGN KEY (material_id) REFERENCES material (id)
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE material ADD CONSTRAINT FK_7CBE7595C54C8C93 FOREIGN KEY (type_id) REFERENCES material_type (id)
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE output_recipe_material ADD CONSTRAINT FK_CB0D94B259D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id) ON DELETE CASCADE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE output_recipe_material ADD CONSTRAINT FK_CB0D94B2E308AC6F FOREIGN KEY (material_id) REFERENCES material (id)
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE recipe ADD CONSTRAINT FK_DA88B137F6B75B26 FOREIGN KEY (machine_id) REFERENCES machine (id)
SQL);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE input_recipe_material DROP FOREIGN KEY FK_77575DA759D8A214
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE input_recipe_material DROP FOREIGN KEY FK_77575DA7E308AC6F
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE material DROP FOREIGN KEY FK_7CBE7595C54C8C93
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE output_recipe_material DROP FOREIGN KEY FK_CB0D94B259D8A214
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE output_recipe_material DROP FOREIGN KEY FK_CB0D94B2E308AC6F
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE recipe DROP FOREIGN KEY FK_DA88B137F6B75B26
SQL);
$this->addSql(<<<'SQL'
DROP TABLE input_recipe_material
SQL);
$this->addSql(<<<'SQL'
DROP TABLE machine
SQL);
$this->addSql(<<<'SQL'
DROP TABLE material
SQL);
$this->addSql(<<<'SQL'
DROP TABLE material_type
SQL);
$this->addSql(<<<'SQL'
DROP TABLE output_recipe_material
SQL);
$this->addSql(<<<'SQL'
DROP TABLE recipe
SQL);
}
}