CakeAccounting/config/Migrations/20241027060406_CreateInitia...

103 lines
3.1 KiB
PHP
Raw Normal View History

2025-08-09 21:07:39 +00:00
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateInitialLookupTables extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
// double entry types
$table = $this->table('de_base_types', ['id' => false, 'primary_key' => ['de_code']]);
$table->addColumn('de_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 45,
'null' => false,
]);
$table->create();
// entity types
$table = $this->table('de_entity_types', ['id' => false, 'primary_key' => ['entity_type_code']]);
$table->addColumn('entity_type_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 45,
'null' => false,
]);
$table->create();
// transaction types
$table = $this->table('de_transaction_types', ['id' => false, 'primary_key' => ['transaction_type_code']]);
$table->addColumn('transaction_type_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 45,
'null' => false,
]);
$table->create();
// bank account types
$table = $this->table('de_bank_account_types', ['id' => false, 'primary_key' => ['bank_account_type_code']]);
$table->addColumn('bank_account_type_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('de_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 45,
'null' => false,
]);
// $table->addForeignKey(
// 'de_code',
// 'de_base_types',
// 'de_code',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'bank_accounts_base_de_code_fk'
// ]
// );
$table->create();
// internal account types
$table = $this->table('de_account_types', ['id' => false, 'primary_key' => ['account_type_code']]);
$table->addColumn('account_type_code', 'string', [
'default' => null,
'limit' => 2,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 45,
'null' => false,
]);
$table->create();
}
}