init
This commit is contained in:
0
app/Database/Migrations/.gitkeep
Normal file
0
app/Database/Migrations/.gitkeep
Normal file
84
app/Database/Migrations/2023-10-19-182027_SuperUser.php
Normal file
84
app/Database/Migrations/2023-10-19-182027_SuperUser.php
Normal 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');
|
||||
}
|
||||
}
|
||||
55
app/Database/Migrations/2023-10-19-185755_SuperGroup.php
Normal file
55
app/Database/Migrations/2023-10-19-185755_SuperGroup.php
Normal 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');
|
||||
}
|
||||
}
|
||||
69
app/Database/Migrations/2023-10-19-211659_Endpoint.php
Normal file
69
app/Database/Migrations/2023-10-19-211659_Endpoint.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user