Archived
1
0
Fork 0

adding base db migrations.

This commit is contained in:
Henrik Hautakoski 2018-03-21 19:12:35 +01:00
parent 3db175d542
commit bf3d78da00
4 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateUserTable extends AbstractMigration
{
public function up()
{
$table = $this->table('user');
$table->addColumn('username', 'string', [
'limit' => 50,
'null' => false
]);
$table->addColumn('email', 'string', [
'limit' => 255,
'null' => false
]);
$table->addColumn('status', 'enum', [
'null' => false,
'default' => 'Active',
'values' => [ 'Active', 'Deleted', 'Suspended']
]);
$table->addColumn('password', 'string', [
'limit' => 255,
'null' => true,
]);
$table->save();
}
}

View file

@ -0,0 +1,36 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateCallbackTable extends AbstractMigration
{
public function up()
{
$table = $this->table('callback');
$table->addColumn('public_id', 'string', [
'length' => 12,
'null' => false,
])->addIndex('public_id', [ 'name' => 'UNIQUE_public_id', 'unique' => true ]);
$table->addColumn('userid', 'integer', [
'null' => true,
])->addForeignKey('userid', 'user', ['id'], [ 'constraint' => 'FK_user' ]);
$table->addColumn('name', 'string', [
'length' => 64,
'null' => false,
]);
$table->addColumn('created_at', 'timestamp', [
'default' => 'CURRENT_TIMESTAMP'
]);
$table->addColumn('last_request', 'timestamp', [
'default' => null,
'null' => true
]);
$table->save();
}
}

View file

@ -0,0 +1,39 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateRequestMetaTable extends AbstractMigration
{
public function up()
{
$table = $this->table('request_meta');
$table->addColumn('callbackid', 'integer');
$table->addForeignKey('callbackid', 'callback', [ 'id' ],
[ 'constraint' => 'FK_callback' ]);
$table->addColumn('source_ip', 'string', [
'limit' => 50,
'null' => true,
]);
$table->addColumn('method', 'enum', [
'null' => false,
'default' => 'GET',
'values' => [ 'GET', 'POST' ]
]);
$table->addColumn('uri', 'string', [
'limit' => 255,
'null' => true,
]);
$table->addColumn('timestamp', 'timestamp', [
'default' => 'CURRENT_TIMESTAMP',
'null' => false,
]);
$table->save();
}
}

View file

@ -0,0 +1,25 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateRequestObjectTable extends AbstractMigration
{
public function up()
{
$table = $this->table('request_object');
$table->addForeignKey('id', 'request_meta', ['id'],
[ 'constraint' => 'FK_request_meta' ]);
$table->addColumn('headers', 'blob', [
'null' => true,
]);
$table->addColumn('body', 'blob', [
'null' => true,
]);
$table->save();
}
}