This commit is contained in:
Naden
2026-04-25 04:41:23 +07:00
commit 7e9668a552
195 changed files with 20254 additions and 0 deletions

View File

View File

@@ -0,0 +1,84 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class SuperUser extends Migration
{
public function up()
{
$db = \Config\Database::connect();
if ($db->getPrefix() && ($db->getPlatform() == 'Postgre')) {
$pr = $db->getPrefix();
$ff = explode('.', $pr);
$db->query('ALTER TABLE ' . $ff[1] . '.super_user ADD CONSTRAINT super_user_pk PRIMARY KEY (super_user_id)');
$db = new \Config\Database;
$dbSelect = $db->default;
$dbSelect['DBPrefix'] = '';
$dbSelect['schema'] = 'Postgre';
$forge = \Config\Database::forge($dbSelect);
$forge->addField([
'super_user_id' => [
'type' => 'VARCHAR',
'constraint' => 200,
],
'super_user_unique' => [
'type' => 'INT',
'constraint' => 255,
'auto_increment' => true,
'unique' => true,
],
'super_group_id' => [
'type' => 'INT',
'constraint' => 5,
],
'domain_id' => [
'type' => 'INT',
'constraint' => 5,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 200,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'username' => [
'type' => 'VARCHAR',
'constraint' => 200,
],
'password' => [
'type' => 'VARCHAR',
'constraint' => 200,
],
'avatar' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'status' => [
'type' => 'INT',
'constraint' => 1,
'null' => true,
],
'token' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'created_at timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP',
'login_date timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP',
'access_at timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP'
]);
$forge->createTable($ff[1] . '.super_user');
$db = \Config\Database::connect();
}
}
public function down()
{
$this->forge->dropTable('super_user');
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class SuperGroup extends Migration
{
public function up()
{
$db = \Config\Database::connect();
if ($db->getPrefix() && ($db->getPlatform() == 'Postgre')) {
$pr = $db->getPrefix();
$ff = explode('.', $pr);
$db = new \Config\Database;
$dbSelect = $db->default;
$dbSelect['DBPrefix'] = '';
$dbSelect['schema'] = 'Postgre';
$forge = \Config\Database::forge($dbSelect);
$forge->addField([
'super_group_id' => [
'type' => 'INT',
'constraint' => 255,
'auto_increment' => true,
],
'super_group_unique' => [
'type' => 'INT',
'constraint' => 255,
'auto_increment' => true,
'unique' => true,
],
'domain_id' => [
'type' => 'INT',
'constraint' => 255,
],
'group_name' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'status' => [
'type' => 'INT',
'constraint' => 1,
'null' => true,
],
'created_at timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP',
]);
$forge->createTable('super_group');
}
}
public function down()
{
$this->forge->dropTable('super_group');
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class Endpoint extends Migration
{
public function up()
{
$db = \Config\Database::connect();
if ($db->getPrefix() && ($db->getPlatform() == 'Postgre')) {
$db->query('CREATE TYPE method AS ENUM ("frontend", "backend")');
$db->query('CREATE TYPE type AS ENUM ("POST", "GET", "PUT", "DELETE")');
$db->query('CREATE TYPE bypass AS ENUM ("0", "1")');
$pr = $db->getPrefix();
$ff = explode('.', $pr);
$db = new \Config\Database;
$dbSelect = $db->default;
$dbSelect['DBPrefix'] = '';
$dbSelect['schema'] = 'Postgre';
$forge = \Config\Database::forge($dbSelect);
$forge->addField([
'endpoint_id' => [
'type' => 'INT',
'constraint' => 255,
'auto_increment' => true,
],
'value' => [
'type' => 'VARCHAR',
'constraint' => 200,
],
'method' => [
'type' => 'ENUM',
'constraint' => ['POST', 'GET', 'PUT', 'DELETE']
],
'type' => [
'type' => 'ENUM',
'constraint' => ['frontend', 'backend'],
'default' => 'backend',
],
'bypass' => [
'type' => 'ENUM',
'constraint' => ['0', '1'],
'default' => '0',
],
'description' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'created_by' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'created_at timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP',
]);
$this->forge->createTable($ff[1] . 'endpoint');
}
}
public function down()
{
$this->forge->dropTable('endpoint');
}
}

View File

@@ -0,0 +1,222 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateIperaAgreementTables extends Migration
{
public function up()
{
$this->forge->addField([
'agreement_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'ipera_type_id' => [
'type' => 'INT',
],
'total_value' => [
'type' => 'DECIMAL',
'constraint' => '15,2',
],
'initial_fee' => [
'type' => 'DECIMAL',
'constraint' => '15,2',
'default' => 0,
],
'tenor_years' => [
'type' => 'INT',
],
'start_date' => [
'type' => 'DATE',
],
'first_year_rule' => [
'type' => 'VARCHAR',
'constraint' => 50,
],
'status' => [
'type' => 'VARCHAR',
'constraint' => 20,
'default' => 'Belum',
],
'produksi_id' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
'panen_id' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
'mitra_id' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
'koperasi_id' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
'rounding_to' => [
'type' => 'INT',
'null' => true,
],
'is_deleted' => [
'type' => 'BOOLEAN',
'default' => false,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_by' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
]);
$this->forge->addKey('agreement_id', true);
$this->forge->addKey('koperasi_id');
$this->forge->addKey('mitra_id');
$this->forge->addKey('ipera_type_id');
$this->forge->addKey('status');
$this->forge->createTable('ipera_agreement', true);
$this->forge->addField([
'schedule_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'agreement_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'year_index' => [
'type' => 'INT',
],
'due_date' => [
'type' => 'DATE',
],
'due_year' => [
'type' => 'INT',
],
'amount' => [
'type' => 'DECIMAL',
'constraint' => '15,2',
],
'status' => [
'type' => 'VARCHAR',
'constraint' => 20,
'default' => 'Pending',
],
'paid_amount' => [
'type' => 'DECIMAL',
'constraint' => '15,2',
'null' => true,
],
'paid_at' => [
'type' => 'DATE',
'null' => true,
],
'proof_url' => [
'type' => 'VARCHAR',
'constraint' => 500,
'null' => true,
],
'proof_id' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
'is_deleted' => [
'type' => 'BOOLEAN',
'default' => false,
],
]);
$this->forge->addKey('schedule_id', true);
$this->forge->addKey('agreement_id');
$this->forge->addKey('status');
$this->forge->createTable('ipera_installment_schedule', true);
$this->forge->addField([
'payment_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'schedule_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'agreement_id' => [
'type' => 'VARCHAR',
'constraint' => 36,
],
'year_index' => [
'type' => 'INT',
],
'amount' => [
'type' => 'DECIMAL',
'constraint' => '15,2',
],
'payment_type' => [
'type' => 'VARCHAR',
'constraint' => 20,
],
'payment_date' => [
'type' => 'DATE',
],
'proof_url' => [
'type' => 'VARCHAR',
'constraint' => 500,
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_by' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
],
]);
$this->forge->addKey('payment_id', true);
$this->forge->addKey('schedule_id');
$this->forge->addKey('agreement_id');
$this->forge->createTable('ipera_payment_history', true);
}
public function down()
{
$this->forge->dropTable('ipera_payment_history', true);
$this->forge->dropTable('ipera_installment_schedule', true);
$this->forge->dropTable('ipera_agreement', true);
}
}