Files
CompanyProject/滴滴淘/diditao/database/migrations/20200511144720_log_api_request.php
2024-09-27 01:32:49 +08:00

45 lines
1.7 KiB
PHP

<?php
use think\migration\Migrator;
use think\migration\db\Column;
class LogApiRequest 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('log_api_record')->setCollation('utf8mb4_general_ci')->setComment('api请求记录表');
$table->addColumn(Column::unsignedInteger('api_id')->setComment('API接口ID'))
->addColumn(Column::unsignedInteger('user_id')->setComment('用户ID')->setDefault(0))
->addColumn(Column::string('api_url')->setComment('请求地址')->setNullable())
->addColumn(Column::json('param')->setComment('参数'))
->addColumn(Column::tinyInteger('status')->setComment('返回状态'))
->addColumn(Column::json('result_data')->setComment('返回数据')->setNullable())
->addColumn(Column::unsignedInteger('create_time')->setComment('创建时间')->setDefault(0))
->addColumn(Column::unsignedInteger('update_time')->setComment('更新时间')->setDefault(0))
->addIndex(['api_id'])
->addIndex(['user_id'])
->create();
}
}