This commit is contained in:
2021-06-28 23:15:13 -04:00
parent 0061a3d920
commit f4a8db56ff
93 changed files with 2422 additions and 0 deletions

View File

@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTables extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('coins')
->addColumn('identifier', 'string')
->addColumn('code', 'string', ['limit' => 5])
->addColumn('name', 'string')
->addColumn('prefix', 'string', ['default' => ''])
->addColumn('suffix', 'string', ['default' => ''])
->addColumn('decimals', 'integer', ['default' => 0])
->addColumn('ref_url', 'text', ['default' => ''])
->create();
$this->table('locations')
->addColumn('name', 'string')
->addColumn('description', 'string')
->create();
$cascade = ['update' => 'CASCADE', 'delete' => 'CASCADE'];
$this->table('wallets')
->addColumn('name', 'string')
->addColumn('location_id', 'integer')
->addForeignKey('location_id', 'locations', 'id', $cascade)
->addColumn('public_address', 'string')
->create();
$this->table('values')
->addColumn('date_time', 'datetime')
->addColumn('coin_id', 'integer')
->addForeignKey('coin_id', 'coins', 'id', $cascade)
->addColumn('value', 'double')
->addColumn('unit_id', 'integer')
->addForeignKey('unit_id', 'coins', 'id', $cascade)
->create();
$this->table('transactions')
->addColumn('date_time', 'datetime')
->addColumn('coin_id', 'integer')
->addForeignKey('coin_id', 'coins', 'id', $cascade)
->addColumn('wallet_id', 'integer')
->addForeignKey('wallet_id', 'wallets', 'id', $cascade)
->addColumn('amount', 'double')
->addColumn('value', 'double')
->addColumn('unit_id', 'integer')
->addForeignKey('unit_id', 'coins', 'id', $cascade)
->create();
$this->table('coin_registers')
->addColumn('type', 'integer')
->addColumn('coin_id', 'integer')
->addForeignKey('coin_id', 'coins', 'id')
->addColumn('date_time', 'datetime')
->create();
}
}

View File

@ -0,0 +1,89 @@
name: crypto
tables:
- name: coins
columns:
- name: id
type: int
unsigned: true
auto_increment: true
- name: code
type: varchar(5)
- name: name
type: varchar(200)
- name: ref_url
type: text
primary_key: id
- name: locations
columns:
- name: id
type: int
unsigned: true
auto_increment: true
- name: name
type: varchar(100)
- name: description
type: varchar(200)
primary_key: id
- name: transactions
columns:
- name: id
type: int
unsigned: true
auto_increment: true
- name: date_time
type: datetime
- name: coin_id
type: int
unsigned: true
- name: wallet_id
type: int
unsigned: true
- name: amount
type: double
- name: value
type: double
- name: unit_id
type: int
unsigned: true
primary_key: id
foreign_keys:
- table: coins
local_column: coin_id
foreign_column: id
- table: wallets
local_column: wallet_id
foreign_column: id
- table: coins
local_column: unit_id
foreign_column: id
- name: values
columns:
- name: id
type: int
unsigned: true
auto_increment: true
- name: date_time
type: datetime
- name: coin_id
type: int
unsigned: true
- name: value
type: double
- name: unit_id
type: int
unsigned: true
primary_key: id
foreign_keys:
- table: coins
local_column: coin_id
foreign_column: id
- table: coins
local_column: unit_id
foreign_column: id
- name: wallets
columns:
- name: id
- name: name
- name: location_id
- name: public_address
primary_key: id