37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260519175041 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create workflow table and seed default Standard workflow';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE workflow (
|
|
id SERIAL NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
is_default BOOLEAN DEFAULT FALSE NOT NULL,
|
|
position INT DEFAULT 0 NOT NULL,
|
|
PRIMARY KEY (id)
|
|
)');
|
|
$this->addSql('CREATE UNIQUE INDEX uniq_workflow_name ON workflow (name)');
|
|
$this->addSql('CREATE UNIQUE INDEX uniq_workflow_one_default ON workflow (is_default) WHERE is_default = TRUE');
|
|
|
|
$this->addSql("INSERT INTO workflow (name, is_default, position) VALUES ('Standard', TRUE, 0)");
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('DROP TABLE workflow');
|
|
}
|
|
}
|