24 lines
803 B
PHP
24 lines
803 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateBlogVisits extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
// create table if it does not exist
|
|
$table = $this->table('blog_visits');
|
|
if (!$table->exists()) {
|
|
$table->addColumn('ip', 'string', ['null' => true, 'limit' => 255])
|
|
->addColumn('useragent', 'text', ['null' => true])
|
|
->addColumn('cnt', 'integer', ['default' => 0])
|
|
->addColumn('first_seen', 'integer', ['null' => true])
|
|
->addColumn('last_seen', 'integer', ['null' => true])
|
|
->addIndex(['ip', 'useragent'], ['unique' => true, 'name' => 'idx_ip_useragent'])
|
|
->create();
|
|
}
|
|
}
|
|
}
|