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(); } }