mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-01 16:12:47 +08:00
48 lines
2.0 KiB
PHP
48 lines
2.0 KiB
PHP
<?php
|
|
|
|
use app\common\ColumnFormat;
|
|
use think\migration\Migrator;
|
|
use think\migration\db\Column;
|
|
|
|
class CreateTableApiKey extends Migrator
|
|
{
|
|
/**
|
|
* Change Method.
|
|
*
|
|
* Write your reversible migrations using this method.
|
|
*
|
|
* More information on writing migrations is available here:
|
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
|
*
|
|
* The following commands can be used in this method and Phinx will
|
|
* automatically reverse them when rolling back:
|
|
*
|
|
* createTable
|
|
* renameTable
|
|
* addColumn
|
|
* renameColumn
|
|
* addIndex
|
|
* addForeignKey
|
|
*
|
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
* with the Table class.
|
|
*/
|
|
public function change()
|
|
{
|
|
$table = $this->table('api_key', ['comment' => 'API密钥表', 'signed' => false]);
|
|
$table->addColumn('admin_id', 'integer', ['limit' => 10, 'signed' => false, 'comment' => '关联管理员ID']);
|
|
$table->addColumn('api_key', 'string', ['limit' => 64, 'comment' => 'API密钥(md5哈希)']);
|
|
$table->addColumn(ColumnFormat::stringNormal('name')->setComment('API Key名称/备注'));
|
|
$table->addColumn(ColumnFormat::integerTypeStatus('status', 1)->setComment('状态,0:禁用,1:启用'));
|
|
$table->addColumn(ColumnFormat::integerTypeStatus('can_write_own')->setComment('可写自己的,0:不可,1:可'));
|
|
$table->addColumn(ColumnFormat::integerTypeStatus('can_write_other')->setComment('可写其他的,0:不可,1:可'));
|
|
$table->addColumn(ColumnFormat::integerTypeStatus('can_delete')->setComment('删除权限,0:不可删除,1:仅删API数据,2:可删所有'));
|
|
$table->addColumn(ColumnFormat::timestamp('create_time'));
|
|
$table->addColumn(ColumnFormat::timestamp('update_time'));
|
|
$table->addColumn(ColumnFormat::timestamp('delete_time'));
|
|
$table->addIndex('admin_id');
|
|
$table->addIndex('api_key', ['unique' => true]);
|
|
$table->create();
|
|
}
|
|
}
|