yunzer/database/migrations/20240321_create_article_view_table.php
2025-05-10 00:46:45 +08:00

17 lines
728 B
PHP

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