refactor(database): ubah tipe kolom dari date/datetime/decimal menjadi string di berbagai tabel

Ubah tipe kolom di database yang sebelumnya menggunakan date, datetime, atau decimal menjadi string. Langkah ini meningkatkan fleksibilitas penyimpanan data.

- `customers` table:
  - Ubah tipe kolom `date_of_birth` dari `date` menjadi `string`.

- `accounts` table:
  - Ubah tipe kolom `opening_date` dari `date` menjadi `string`.
  - Ubah tipe kolom `closure_date` dari `date` menjadi `string`.
  - Revisi kolom `start_year_bal` menjadi `string` dengan parameter yang disesuaikan.

- `ft_txn_type_condition` table:
  - Ubah tipe kolom `date_time` dari `dateTime` menjadi `string`.

- `data_captures` table:
  - Ubah tipe kolom `value_date`, `exposure_date`, dan `accounting_date` dari `date` menjadi `string`.
  - Ubah tipe kolom `date_time` dari `dateTime` menjadi `string`.
  - Ubah tipe kolom `amount_lcy`, `amount_fcy`, dan `exchange_rate` dari `decimal` menjadi `string`.

- `temp_arrangements` table:
  - Ubah tipe kolom `orig_contract_date` dan `start_date` dari `date` menjadi `string`.

- Model changes:
  - Hapus properti `casts` dari model berikut:
    - `AtmTransaction`
    - `DataCapture`
    - `FtTxnTypeCondition`
This commit is contained in:
daengdeni
2025-05-24 17:04:31 +07:00
parent b894a2c9c4
commit 562cc94822
9 changed files with 221 additions and 31 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change date_of_birth column from date to string type
*/
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
// First modify the column to string type
$table->string('date_of_birth')->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change date_of_birth column back to date type
*/
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
// Convert back to date type
$table->date('date_of_birth')->nullable()->change();
});
}
};

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change date fields to string type in accounts table
*/
public function up(): void
{
Schema::table('accounts', function (Blueprint $table) {
// Change opening_date from date to string
$table->string('opening_date')->nullable()->change();
// Change closure_date from date to string
$table->string('closure_date')->nullable()->change();
// Fix the start_year_bal column which has incorrect parameters
// First drop the column
$table->string('start_year_bal',255)->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change string fields back to date type
*/
public function down(): void
{
Schema::table('accounts', function (Blueprint $table) {
// Change opening_date back to date
$table->date('opening_date')->nullable()->change();
// Change closure_date back to date
$table->date('closure_date')->nullable()->change();
// Drop and recreate start_year_bal with original definition
$table->string('start_year_bal',15)->nullable()->change();
});
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change date_time column from dateTime to string type
*/
public function up(): void
{
Schema::table('ft_txn_type_condition', function (Blueprint $table) {
// Change date_time from dateTime to string
$table->string('date_time')->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change date_time column back to dateTime type
*/
public function down(): void
{
Schema::table('ft_txn_type_condition', function (Blueprint $table) {
// Change date_time back to dateTime
$table->dateTime('date_time')->nullable()->change();
});
}
};

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change date and dateTime fields to string type in data_captures table
*/
public function up(): void
{
Schema::table('data_captures', function (Blueprint $table) {
// Change date fields to string
$table->string('value_date')->nullable()->change();
$table->string('exposure_date')->nullable()->change();
$table->string('accounting_date')->nullable()->change();
// Change dateTime field to string
$table->string('date_time')->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change string fields back to date and dateTime types
*/
public function down(): void
{
Schema::table('data_captures', function (Blueprint $table) {
// Change string fields back to date
$table->date('value_date')->nullable()->change();
$table->date('exposure_date')->nullable()->change();
$table->date('accounting_date')->nullable()->change();
// Change string field back to dateTime
$table->dateTime('date_time')->nullable()->change();
});
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change decimal fields to string type in data_captures table
*/
public function up(): void
{
Schema::table('data_captures', function (Blueprint $table) {
// Change decimal fields to string
$table->string('amount_lcy')->nullable()->change();
$table->string('amount_fcy')->nullable()->change();
$table->string('exchange_rate')->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change string fields back to decimal types
*/
public function down(): void
{
Schema::table('data_captures', function (Blueprint $table) {
// Change string fields back to decimal with original precision and scale
$table->decimal('amount_lcy', 20, 2)->nullable()->change();
$table->decimal('amount_fcy', 20, 2)->nullable()->change();
$table->decimal('exchange_rate', 20, 6)->nullable()->change();
});
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Change date fields to string type in temp_arrangements table
*/
public function up(): void
{
Schema::table('temp_arrangements', function (Blueprint $table) {
// Change date fields to string
$table->string('orig_contract_date')->nullable()->change();
$table->string('start_date')->nullable()->change();
});
}
/**
* Reverse the migrations.
* Change string fields back to date type
*/
public function down(): void
{
Schema::table('temp_arrangements', function (Blueprint $table) {
// Change string fields back to date
$table->date('orig_contract_date')->nullable()->change();
$table->date('start_date')->nullable()->change();
});
}
};