gruby refaktor otyły panie
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
final class CreateUsersTable extends AbstractMigration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$table = $this->table('users');
|
||||
$table->addColumn('username', 'string')
|
||||
->addColumn('password', 'string')
|
||||
->save();
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->table('users')->drop()->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
final class CreateContentsTable extends AbstractMigration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$table = $this->table('contents');
|
||||
$table->addColumn('key', 'string')
|
||||
->addColumn('content', 'text')
|
||||
->save();
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->table('contents')->drop()->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
final class CreateAccessLogs extends AbstractMigration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$table = $this->table('access_logs');
|
||||
$table->addColumn('username', 'string')
|
||||
->addColumn('password', 'string')
|
||||
->addColumn('remote_ip', 'string')
|
||||
->addColumn('user_agent', 'text')
|
||||
->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->save();
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->table('access_logs')->drop()->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user