17 lines
		
	
	
		
			728 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			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();
 | |
|     }
 | |
| } 
 | 
