103 lines
3.0 KiB
PHP
103 lines
3.0 KiB
PHP
|
<?php
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
use Migrations\AbstractMigration;
|
||
|
|
||
|
class CreateExampleAccounts 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
|
||
|
{
|
||
|
$table = $this->table('de_account_templates');
|
||
|
$table->addColumn('name', 'string', [
|
||
|
'default' => null,
|
||
|
'limit' => 45,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('deleted', 'datetime', [
|
||
|
'default' => null,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
$table->create();
|
||
|
|
||
|
$table = $this->table('de_templated_accounts');
|
||
|
$table->addColumn('account_number', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('account_template_id', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('parent_id', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
$table->addColumn('lft', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('rght', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('account_type_code', 'string', [
|
||
|
'default' => null,
|
||
|
'limit' => 2,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('account_limit', 'integer', [
|
||
|
'default' => null,
|
||
|
'limit' => 11,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
$table->addColumn('can_credit', 'boolean', [
|
||
|
'default' => true,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('can_debit', 'boolean', [
|
||
|
'default' => true,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('name', 'string', [
|
||
|
'default' => null,
|
||
|
'limit' => 255,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
// $table->addForeignKey(
|
||
|
// 'ledger_type_code',
|
||
|
// 'de_ledger_types',
|
||
|
// 'ledger_type_code',
|
||
|
// [
|
||
|
// 'update' => 'RESTRICT',
|
||
|
// 'delete' => 'RESTRICT',
|
||
|
// 'constraint' => 'de_templated_ledgers_de_ledger_type_fk',
|
||
|
// ]
|
||
|
// );
|
||
|
// $table->addForeignKey(
|
||
|
// 'account_type_code',
|
||
|
// 'de_internal_account_types',
|
||
|
// 'account_type_code',
|
||
|
// [
|
||
|
// 'update' => 'RESTRICT',
|
||
|
// 'delete' => 'RESTRICT',
|
||
|
// 'constraint' => 'de_templated_ledgers_de_account_type_code_fk',
|
||
|
// ]
|
||
|
// );
|
||
|
$table->addIndex('parent_id', ['unique' => false]);
|
||
|
$table->addIndex('lft', ['unique' => false]);
|
||
|
$table->create();
|
||
|
}
|
||
|
}
|