SQL
CREATE TABLE collector_assignments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
collector_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
assigned_date DATETIME DEFAULT CURRENT_TIMESTAMP,
status TEXT DEFAULT 'active' CHECK(status IN ('active', 'completed', 'cancelled')),
notes TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (collector_id) REFERENCES collectors(id),
FOREIGN KEY (customer_id) REFERENCES customers(id),
UNIQUE(collector_id, customer_id)
)
Columns
| Column | Data type | Allow null | Primary key | Actions |
|---|---|---|---|---|
id |
INTEGER |
✓ | ✓ | Rename | Drop |
collector_id |
INTEGER |
Rename | Drop | ||
customer_id |
INTEGER |
Rename | Drop | ||
assigned_date |
DATETIME |
✓ | Rename | Drop | |
status |
TEXT |
✓ | Rename | Drop | |
notes |
TEXT |
✓ | Rename | Drop | |
created_at |
DATETIME |
✓ | Rename | Drop | |
updated_at |
DATETIME |
✓ | Rename | Drop |
Foreign Keys
| Column | Destination |
|---|---|
customer_id |
customers.id |
collector_id |
collectors.id |
Indexes
| Name | Columns | Unique | SQL | Drop? |
|---|---|---|---|---|
| idx_collector_assignments_collector_id |
collector_id
|
SQL | Drop | |
| idx_collector_assignments_customer_id |
customer_id
|
SQL | Drop | |
| sqlite_autoindex_collector_assignments_1 |
|
✓ | SQL | Drop |
Triggers
| Name | SQL | Drop? |
|---|---|---|
| update_collector_assignments_updated_at | SQL | Drop |