diff --git a/database/migrations/2025_05_24_082504_remove_id_from_account_balances_table.php b/database/migrations/2025_05_24_082504_remove_id_from_account_balances_table.php new file mode 100644 index 0000000..b26da39 --- /dev/null +++ b/database/migrations/2025_05_24_082504_remove_id_from_account_balances_table.php @@ -0,0 +1,42 @@ +dropUnique(['account_number', 'period']); + + // Drop the id column and its auto-increment primary key + $table->dropColumn('id'); + + // Set the composite primary key + $table->primary(['account_number', 'period']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('account_balances', function (Blueprint $table) { + // Drop the composite primary key + $table->dropPrimary(['account_number', 'period']); + + // Add back the id column with auto-increment + $table->id()->first(); + + // Re-add the unique constraint + $table->unique(['account_number', 'period']); + }); + } + };