yunzer/database/migrations/20240321_create_article_view_table.php
2025-06-07 09:15:14 +08:00

34 lines
1.2 KiB
PHP

<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
use think\migration\Migrator;
use think\migration\db\Column;
class CreateArticleViewTable extends Migrator
{
public function change()
{
$table = $this->table('yz_article_view', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci']);
$table
->addColumn('article_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '文章ID'])
->addColumn('ip', 'string', ['limit' => 50, 'null' => false, 'comment' => '访问IP'])
->addColumn('view_time', 'integer', ['signed' => false, 'null' => false, 'comment' => '访问时间'])
->addIndex(['article_id', 'ip', 'view_time'], ['name' => 'idx_article_ip_time'])
->create();
}
}