migrations/Version20230301191819.php line 1
<?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 Version20230301191819 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 shop_item (id INT AUTO_INCREMENT NOT NULL, template_id INT DEFAULT NULL, material_id INT DEFAULT NULL, recipe_id INT DEFAULT NULL, quantity INT NOT NULL, in_stock_date DATE NOT NULL, INDEX IDX_DEE9C3655DA0FB8 (template_id), INDEX IDX_DEE9C365E308AC6F (material_id), INDEX IDX_DEE9C36559D8A214 (recipe_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_shop_item (user_id INT NOT NULL, shop_item_id INT NOT NULL, INDEX IDX_DE094E81A76ED395 (user_id), INDEX IDX_DE094E81115C1274 (shop_item_id), PRIMARY KEY(user_id, shop_item_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE shop_item ADD CONSTRAINT FK_DEE9C3655DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id)');
$this->addSql('ALTER TABLE shop_item ADD CONSTRAINT FK_DEE9C365E308AC6F FOREIGN KEY (material_id) REFERENCES material (id)');
$this->addSql('ALTER TABLE shop_item ADD CONSTRAINT FK_DEE9C36559D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
$this->addSql('ALTER TABLE user_shop_item ADD CONSTRAINT FK_DE094E81A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_shop_item ADD CONSTRAINT FK_DE094E81115C1274 FOREIGN KEY (shop_item_id) REFERENCES shop_item (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE material ADD buy_price DOUBLE PRECISION DEFAULT NULL, ADD sell_price DOUBLE PRECISION DEFAULT NULL, ADD shop_inventory TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE recipe ADD buy_price DOUBLE PRECISION DEFAULT NULL, ADD shop_inventory TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE template ADD buy_price DOUBLE PRECISION DEFAULT NULL, ADD shop_inventory TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE shop_item DROP FOREIGN KEY FK_DEE9C3655DA0FB8');
$this->addSql('ALTER TABLE shop_item DROP FOREIGN KEY FK_DEE9C365E308AC6F');
$this->addSql('ALTER TABLE shop_item DROP FOREIGN KEY FK_DEE9C36559D8A214');
$this->addSql('ALTER TABLE user_shop_item DROP FOREIGN KEY FK_DE094E81A76ED395');
$this->addSql('ALTER TABLE user_shop_item DROP FOREIGN KEY FK_DE094E81115C1274');
$this->addSql('DROP TABLE shop_item');
$this->addSql('DROP TABLE user_shop_item');
$this->addSql('ALTER TABLE material DROP buy_price, DROP sell_price, DROP shop_inventory');
$this->addSql('ALTER TABLE recipe DROP buy_price, DROP shop_inventory');
$this->addSql('ALTER TABLE template DROP buy_price, DROP shop_inventory');
}
}