feat: add template_id column to invoices table and update_invoice_template command

This commit is contained in:
Your Name
2026-02-18 14:37:26 +02:00
parent 4a45713c77
commit 6a252facf6
3 changed files with 97 additions and 7 deletions

View File

@@ -111,6 +111,22 @@ pub fn init_db(conn: &Connection) -> Result<(), rusqlite::Error> {
[],
)?;
// Migrate invoices table — add template_id column (safe to re-run)
let invoice_migrations = [
"ALTER TABLE invoices ADD COLUMN template_id TEXT DEFAULT 'clean'",
];
for sql in &invoice_migrations {
match conn.execute(sql, []) {
Ok(_) => {}
Err(e) => {
let msg = e.to_string();
if !msg.contains("duplicate column") {
return Err(e);
}
}
}
}
conn.execute(
"CREATE TABLE IF NOT EXISTS invoice_items (
id INTEGER PRIMARY KEY AUTOINCREMENT,