Simplify database schema: remove card_type, card_id, add card_number
Refactor the database schema to better model the data relationships: Schema changes: - Removed cards.card_type (redundant, identical to card_number) - Removed transactions.card_id (unnecessary indirection) - Added transactions.card_number (stores card number for all transactions) - Made cards.customer_id NOT NULL (every card must belong to a customer) - Made transactions.customer_id nullable (NULL for anonymized transactions) Import logic changes: - Only create cards for known customers (transactions with customer_number) - Store card_number for ALL transactions (including anonymized) - Skip cards/customer creation for anonymized transactions Additional changes: - Add 'db reset' command to drop and recreate database - Update migration file with new schema This simplifies queries and better reflects the data model: - Cards table: authoritative mapping of card_number -> customer_id - Transactions table: stores all raw data including anonymized cards - Customer relationship via JOIN on card_number for known customers
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
pub mod db;
|
||||
pub mod import;
|
||||
|
||||
pub use db::run_db_setup;
|
||||
pub use db::{run_db_reset, run_db_setup};
|
||||
pub use import::run_import;
|
||||
|
||||
Reference in New Issue
Block a user