pramodmisra commited on
Commit
a55e4f2
·
verified ·
1 Parent(s): 161f628

Update start.py

Browse files
Files changed (1) hide show
  1. start.py +10 -1
start.py CHANGED
@@ -26,7 +26,16 @@ def add_column_if_missing(db_path, table, column, col_type):
26
  db_path = "/data/app.db"
27
  print("Checking for schema migrations...")
28
  add_column_if_missing(db_path, "producers", "email", "VARCHAR(255)")
29
- add_column_if_missing(db_path, "approvals", "approval_token", "VARCHAR(64) UNIQUE")
 
 
 
 
 
 
 
 
 
30
  print("Schema migrations complete.")
31
 
32
 
 
26
  db_path = "/data/app.db"
27
  print("Checking for schema migrations...")
28
  add_column_if_missing(db_path, "producers", "email", "VARCHAR(255)")
29
+ add_column_if_missing(db_path, "approvals", "approval_token", "VARCHAR(64)")
30
+ # Add unique index separately (SQLite doesn't support UNIQUE in ALTER TABLE)
31
+ conn = sqlite3.connect(db_path)
32
+ try:
33
+ conn.execute("CREATE UNIQUE INDEX IF NOT EXISTS ix_approvals_approval_token ON approvals(approval_token)")
34
+ conn.commit()
35
+ print(" Added unique index on approvals.approval_token")
36
+ except Exception as e:
37
+ print(f" Index already exists or skipped: {e}")
38
+ conn.close()
39
  print("Schema migrations complete.")
40
 
41