migrations/Version20240524175154.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20240524175154 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return 'Create PictureNet table';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         $table $schema->createTable('picture_net');
  18.         $table->addColumn('id''integer', ['autoincrement' => true]);
  19.         $table->addColumn('net_id''integer', ['notnull' => false]);
  20.         $table->addColumn('link''text', ['notnull' => false]);
  21.         $table->setPrimaryKey(['id']);
  22.         $fileTable $schema->createTable('picture_net_file');
  23.         $fileTable->addColumn('picture_net_id''integer');
  24.         $fileTable->addColumn('file_id''integer');
  25.         $fileTable->setPrimaryKey(['picture_net_id''file_id']);
  26.         $fileTable->addForeignKeyConstraint('picture_net', ['picture_net_id'], ['id'], ['onDelete' => 'CASCADE']);
  27.         $fileTable->addForeignKeyConstraint('file', ['file_id'], ['id'], ['onDelete' => 'CASCADE']);
  28.     }
  29.     public function down(Schema $schema) : void
  30.     {
  31.         $schema->dropTable('picture_net_file');
  32.         $schema->dropTable('picture_net');
  33.     }
  34. }