From 566dd1e4e77c630e5364b323691aa20c60867318 Mon Sep 17 00:00:00 2001 From: daengdeni Date: Sat, 24 May 2025 09:04:15 +0700 Subject: [PATCH] refactor(database): update primary key in processed_statements table - Menghapus kolom `id` dari tabel `processed_statements` dan sekaligus menghapus primary key auto-increment terkait. - Menetapkan kombinasi kolom `account_number`, `period`, dan `sequence_no` sebagai keys baru dengan composite primary key untuk memastikan setiap record bersifat unik. - Menambahkan kemampuan rollback pada migration untuk mengembalikan struktur ke kondisi awal: - Menghapus composite primary key pada kolom `account_number`, `period`, dan `sequence_no`. - Menambahkan kembali kolom `id` sebagai auto-increment primary key di posisi paling awal tabel. --- ...ove_id_from_processed_statements_table.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2025_05_24_090125_remove_id_from_processed_statements_table.php diff --git a/database/migrations/2025_05_24_090125_remove_id_from_processed_statements_table.php b/database/migrations/2025_05_24_090125_remove_id_from_processed_statements_table.php new file mode 100644 index 0000000..581f3f0 --- /dev/null +++ b/database/migrations/2025_05_24_090125_remove_id_from_processed_statements_table.php @@ -0,0 +1,37 @@ +dropColumn('id'); + + // Set the composite primary key using account_number, period, and sequence_no + // This combination should be unique for each record + $table->primary(['account_number', 'period', 'sequence_no']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('processed_statements', function (Blueprint $table) { + // Drop the composite primary key + $table->dropPrimary(['account_number', 'period', 'sequence_no']); + + // Add back the id column with auto-increment + $table->id()->first(); + }); + } +};