SQL
CREATE TABLE agent_transactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
agent_id INTEGER NOT NULL,
transaction_type TEXT NOT NULL CHECK (transaction_type IN ('deposit', 'withdrawal', 'voucher_sale', 'monthly_payment', 'commission', 'balance_request')),
amount DECIMAL(15,2) NOT NULL,
description TEXT,
reference_id TEXT,
status TEXT DEFAULT 'completed' CHECK (status IN ('pending', 'completed', 'failed', 'cancelled')),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (agent_id) REFERENCES agents(id) ON DELETE CASCADE
)
Columns
| Column | Data type | Allow null | Primary key | Actions |
|---|---|---|---|---|
id |
INTEGER |
✓ | ✓ | Rename | Drop |
agent_id |
INTEGER |
Rename | Drop | ||
transaction_type |
TEXT |
Rename | Drop | ||
amount |
DECIMAL(15,2) |
Rename | Drop | ||
description |
TEXT |
✓ | Rename | Drop | |
reference_id |
TEXT |
✓ | Rename | Drop | |
status |
TEXT |
✓ | Rename | Drop | |
created_at |
DATETIME |
✓ | Rename | Drop |
Foreign Keys
| Column | Destination |
|---|---|
agent_id |
agents.id |
Indexes
| Name | Columns | Unique | SQL | Drop? |
|---|---|---|---|---|
| idx_agent_transactions_agent_id |
agent_id
|
SQL | Drop | |
| idx_agent_transactions_created_at |
created_at
|
SQL | Drop | |
| idx_agent_transactions_type |
transaction_type
|
SQL | Drop |