<?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 Version20240524175154 extends AbstractMigration
{
public function getDescription() : string
{
return 'Create PictureNet table';
}
public function up(Schema $schema) : void
{
$table = $schema->createTable('picture_net');
$table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('net_id', 'integer', ['notnull' => false]);
$table->addColumn('link', 'text', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$fileTable = $schema->createTable('picture_net_file');
$fileTable->addColumn('picture_net_id', 'integer');
$fileTable->addColumn('file_id', 'integer');
$fileTable->setPrimaryKey(['picture_net_id', 'file_id']);
$fileTable->addForeignKeyConstraint('picture_net', ['picture_net_id'], ['id'], ['onDelete' => 'CASCADE']);
$fileTable->addForeignKeyConstraint('file', ['file_id'], ['id'], ['onDelete' => 'CASCADE']);
}
public function down(Schema $schema) : void
{
$schema->dropTable('picture_net_file');
$schema->dropTable('picture_net');
}
}