MCPcopy
hub / github.com/openai/plugins / apply_migrations

Function apply_migrations

plugins/codex-security/scripts/workbench_db.py:416–445  ·  view source on GitHub ↗
(connection: sqlite3.Connection)

Source from the content-addressed store, hash-verified

414
415
416def apply_migrations(connection: sqlite3.Connection) -> None:
417 connection.commit()
418 connection.execute("BEGIN IMMEDIATE")
419 try:
420 connection.execute(
421 """
422 CREATE TABLE IF NOT EXISTS schema_migrations (
423 version INTEGER PRIMARY KEY,
424 name TEXT NOT NULL,
425 applied_at TEXT NOT NULL
426 )
427 """
428 )
429 normalize_pre_release_migrations(connection)
430 applied = {
431 row["version"] for row in connection.execute("SELECT version FROM schema_migrations")
432 }
433 for version, name, sql in MIGRATIONS:
434 if version in applied:
435 continue
436 for statement in sql_statements(sql):
437 connection.execute(statement)
438 connection.execute(
439 "INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)",
440 (version, name, now()),
441 )
442 connection.commit()
443 except BaseException:
444 connection.rollback()
445 raise
446
447
448def normalize_pre_release_migrations(connection: sqlite3.Connection) -> None:

Callers 1

connectFunction · 0.85

Calls 3

sql_statementsFunction · 0.85
nowFunction · 0.85

Tested by

no test coverage detected