CREATE TABLE IF NOT EXISTS import_batches ( id INTEGER PRIMARY KEY AUTOINCREMENT, filename TEXT NOT NULL, bank_name TEXT NOT NULL DEFAULT '', card_type TEXT NOT NULL DEFAULT '', account_id INTEGER REFERENCES accounts(id) ON DELETE SET NULL, imported_count INTEGER NOT NULL DEFAULT 0, skipped_count INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')) ); ALTER TABLE transactions ADD COLUMN counterparty TEXT NOT NULL DEFAULT ''; ALTER TABLE transactions ADD COLUMN import_batch_id INTEGER REFERENCES import_batches(id) ON DELETE SET NULL; CREATE INDEX IF NOT EXISTS idx_transactions_import_batch ON transactions(import_batch_id); CREATE INDEX IF NOT EXISTS idx_transactions_counterparty ON transactions(counterparty);