43 lines
1.9 KiB
PHP
43 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Migration_Add_company_invoice_settings extends CI_Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if (!$this->db->table_exists('companies')) return;
|
|
|
|
$columns = array(
|
|
'phone' => array('type' => 'VARCHAR', 'constraint' => 60, 'null' => true, 'after' => 'address'),
|
|
'email' => array('type' => 'VARCHAR', 'constraint' => 120, 'null' => true, 'after' => 'phone'),
|
|
'logo_path' => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => true, 'after' => 'email'),
|
|
);
|
|
foreach ($columns as $name => $definition) {
|
|
if (!$this->db->field_exists($name, 'companies')) $this->dbforge->add_column('companies', array($name => $definition));
|
|
}
|
|
|
|
if (!$this->db->table_exists('company_bank_accounts')) {
|
|
$this->db->query("CREATE TABLE `company_bank_accounts` (
|
|
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`company_id` BIGINT UNSIGNED NOT NULL,
|
|
`bank_name` VARCHAR(100) NOT NULL,
|
|
`account_number` VARCHAR(100) NOT NULL,
|
|
`account_holder` VARCHAR(150) NOT NULL,
|
|
`currency` CHAR(3) NOT NULL DEFAULT 'IDR',
|
|
`is_primary` TINYINT(1) NOT NULL DEFAULT 0,
|
|
`is_active` TINYINT(1) NOT NULL DEFAULT 1,
|
|
`created_at` DATETIME NOT NULL,
|
|
`updated_at` DATETIME NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uq_company_bank_account` (`company_id`,`account_number`),
|
|
KEY `idx_company_bank_active` (`company_id`,`is_active`,`is_primary`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
throw new RuntimeException('Pengaturan identitas dan rekening perusahaan dipertahankan.');
|
|
}
|
|
}
|