34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateUserPermissionTemplate extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if ($this->getEnvironment() == "thetool") {
|
|
if (!$this->hasTable('UserPermissionTemplate')) {
|
|
$table = $this->table('UserPermissionTemplate', ['id' => false, 'primary_key' => ['id']]);
|
|
$table->addColumn('id', 'integer', ['identity' => true, 'signed' => false])
|
|
->addColumn('name', 'string', ['limit' => 255, 'null' => false])
|
|
->addColumn('permissions', 'text', ['null' => false])
|
|
->addColumn('create', 'integer', ['null' => false])
|
|
->addColumn('createBy', 'integer', ['null' => false])
|
|
->addIndex(['name'], ['unique' => true])
|
|
->create();
|
|
}
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if ($this->getEnvironment() == "thetool") {
|
|
if ($this->hasTable('UserPermissionTemplate')) {
|
|
$this->table('UserPermissionTemplate')->drop()->save();
|
|
}
|
|
}
|
|
}
|
|
}
|