File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -276,15 +276,25 @@ def _init_db_sync() -> None:
276276 # transaction as failed after any error). Using separate
277277 # transactions avoids SAVEPOINTs, which are unreliable with
278278 # pysqlite's default transaction handling.
279+ is_pg = sync_url .startswith ("postgresql" )
279280 for col , definition in [
280281 ("defaultOpen" , "INTEGER DEFAULT 0" ),
281282 ("waitForAnswer" , "INTEGER" ),
282283 ]:
283284 try :
284285 with engine .begin () as conn :
285- conn .execute (
286- text (f'ALTER TABLE steps ADD COLUMN "{ col } " { definition } ' )
287- )
286+ if is_pg :
287+ conn .execute (
288+ text (
289+ f'ALTER TABLE steps ADD COLUMN IF NOT EXISTS "{ col } " { definition } '
290+ )
291+ )
292+ else :
293+ conn .execute (
294+ text (
295+ f'ALTER TABLE steps ADD COLUMN "{ col } " { definition } '
296+ )
297+ )
288298 except (OperationalError , ProgrammingError ):
289299 pass # column already exists
290300
You can’t perform that action at this time.
0 commit comments