feat: reconcile dossier timelines with billing
This commit is contained in:
@@ -208,6 +208,7 @@ def _create_schema(conn):
|
||||
price TEXT,
|
||||
qty TEXT,
|
||||
sum TEXT,
|
||||
vat_rate TEXT,
|
||||
vat_mode TEXT NOT NULL DEFAULT 'with_vat',
|
||||
source_document_id TEXT REFERENCES documents(id) ON DELETE CASCADE,
|
||||
closed_by_document_id TEXT REFERENCES documents(id) ON DELETE SET NULL,
|
||||
@@ -250,6 +251,16 @@ def _create_schema(conn):
|
||||
CREATE INDEX IF NOT EXISTS idx_exceptions_dossier ON exceptions_queue(dossier_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_exceptions_batch ON exceptions_queue(batch_id);
|
||||
""")
|
||||
# Existing /tmp databases survive application restarts. Additive migrations
|
||||
# therefore inspect the live schema before ALTER TABLE, while fresh databases
|
||||
# receive the same column from the CREATE TABLE definition above.
|
||||
timeline_columns = {
|
||||
row["name"] for row in conn.execute("PRAGMA table_info(timeline_intervals)").fetchall()
|
||||
}
|
||||
if "vat_rate" not in timeline_columns:
|
||||
conn.execute("ALTER TABLE timeline_intervals ADD COLUMN vat_rate TEXT")
|
||||
if not getattr(_local, "in_transaction", False):
|
||||
conn.commit()
|
||||
|
||||
|
||||
def cleanup_db():
|
||||
|
||||
Reference in New Issue
Block a user