Migraciones
This commit is contained in:
12
db/migrations/20210315223928_inicial_load.php
Normal file
12
db/migrations/20210315223928_inicial_load.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class InicialLoad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change()
|
||||
{
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
}
|
||||
}
|
40
db/migrations/20210315235617_create_currencies.php
Normal file
40
db/migrations/20210315235617_create_currencies.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCurrencies extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change()
|
||||
{
|
||||
$this->table('currencies', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
'identity' => 'enable',
|
||||
])
|
||||
->addColumn('code', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 5,
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('name', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'code',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
77
db/migrations/20210315235815_create_values.php
Normal file
77
db/migrations/20210315235815_create_values.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateValues extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change()
|
||||
{
|
||||
$this->table('values', [
|
||||
'id' => false,
|
||||
'primary_key' => ['currency_id', 'date_time', 'base_id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('currency_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
])
|
||||
->addColumn('date_time', 'datetime', [
|
||||
'null' => false,
|
||||
'after' => 'currency_id',
|
||||
])
|
||||
->addColumn('value', 'double', [
|
||||
'null' => false,
|
||||
'after' => 'date_time',
|
||||
])
|
||||
->addColumn('base_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
'after' => 'value',
|
||||
])
|
||||
->addIndex(['currency_id'], [
|
||||
'name' => 'currency_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['base_id'], [
|
||||
'name' => 'base_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->create();
|
||||
$this->table('currencies', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => '10',
|
||||
'signed' => false,
|
||||
'identity' => 'enable',
|
||||
])
|
||||
->addColumn('code', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 5,
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('name', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
'encoding' => 'utf8mb4',
|
||||
'after' => 'code',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user