migrations/Version20240207093320.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\DBAL\Types\Types;
  6. use Doctrine\Migrations\AbstractMigration;
  7. final class Version20240207093320 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Create initial tables with INT id for cmcm_request and resource_id field';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         // Create process table first (referenced by other tables)
  16.         $processTable $schema->createTable('process');
  17.         $processTable->addColumn('id'Types::STRING, ['length' => 255]);
  18.         $processTable->addColumn('process_type'Types::STRING, ['length' => 255]);
  19.         $processTable->setPrimaryKey(['id']);
  20.         // Create cmcm_request table
  21.         $cmcmRequestTable $schema->createTable('cmcm_request');
  22.         $cmcmRequestTable->addColumn('id'Types::INTEGER, ['autoincrement' => true]);
  23.         $cmcmRequestTable->addColumn('process_id'Types::STRING, ['length' => 255]);
  24.         $cmcmRequestTable->addColumn('resource_id'Types::STRING, ['length' => 255'notnull' => false]);
  25.         $cmcmRequestTable->addColumn('document_id'Types::STRING, ['length' => 255'notnull' => false]);
  26.         $cmcmRequestTable->addColumn('created_at'Types::DATETIME_IMMUTABLE);
  27.         $cmcmRequestTable->addColumn('updated_at'Types::DATETIME_IMMUTABLE, ['notnull' => false]);
  28.         $cmcmRequestTable->addColumn('status'Types::STRING, ['length' => 255]);
  29.         $cmcmRequestTable->addColumn('title'Types::STRING, ['length' => 255'notnull' => false]);
  30.         $cmcmRequestTable->setPrimaryKey(['id']);
  31.         $cmcmRequestTable->addUniqueIndex(['process_id'], 'uniq_cmcm_request_process_id');
  32.         $cmcmRequestTable->addUniqueIndex(['resource_id'], 'uniq_resource_id');
  33.         $cmcmRequestTable->addForeignKeyConstraint('process', ['process_id'], ['id'], [], 'FK_258CBA37EC2F574');
  34.         // Create extranet_member_leaving_process table
  35.         $leavingProcessTable $schema->createTable('extranet_member_leaving_process');
  36.         $leavingProcessTable->addColumn('id'Types::STRING, ['length' => 255]);
  37.         $leavingProcessTable->addColumn('leaving_at'Types::DATETIME_IMMUTABLE);
  38.         $leavingProcessTable->addColumn('leaving_reason'Types::STRING, ['length' => 255]);
  39.         $leavingProcessTable->setPrimaryKey(['id']);
  40.         $leavingProcessTable->addForeignKeyConstraint('process', ['id'], ['id'], ['onDelete' => 'CASCADE'], 'FK_1EA2C397BF396750');
  41.     }
  42.     public function down(Schema $schema): void
  43.     {
  44.         $schema->dropTable('cmcm_request');
  45.         $schema->dropTable('extranet_member_leaving_process');
  46.         $schema->dropTable('process');
  47.     }
  48. }