31 lines
1.4 KiB
PHP
31 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace DoctrineMigrations;
|
||
|
|
|
||
|
|
use Doctrine\DBAL\Schema\Schema;
|
||
|
|
use Doctrine\Migrations\AbstractMigration;
|
||
|
|
|
||
|
|
final class Version20260505073300 extends AbstractMigration
|
||
|
|
{
|
||
|
|
public function getDescription(): string
|
||
|
|
{
|
||
|
|
return 'Create admin users and script mappings.';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function up(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('CREATE TABLE admin_user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL, password_hash VARCHAR(255) NOT NULL, roles CLOB NOT NULL)');
|
||
|
|
$this->addSql('CREATE UNIQUE INDEX uniq_admin_user_username ON admin_user (username)');
|
||
|
|
$this->addSql('CREATE TABLE script_mapping (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, public_path VARCHAR(255) NOT NULL, repository_url VARCHAR(2048) NOT NULL, git_ref VARCHAR(255) NOT NULL, repository_file_path VARCHAR(1024) NOT NULL, access_token CLOB DEFAULT NULL, active BOOLEAN NOT NULL, last_sync_status VARCHAR(32) NOT NULL, last_successful_sync_at DATETIME DEFAULT NULL, last_sync_error CLOB DEFAULT NULL, cache_key VARCHAR(1024) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL)');
|
||
|
|
$this->addSql('CREATE UNIQUE INDEX uniq_script_mapping_public_path ON script_mapping (public_path)');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('DROP TABLE script_mapping');
|
||
|
|
$this->addSql('DROP TABLE admin_user');
|
||
|
|
}
|
||
|
|
}
|