feat: add template_id column to invoices table and update_invoice_template command
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user