MCPcopy
hub / github.com/tirth8205/code-review-graph / get_schema_version

Function get_schema_version

code_review_graph/migrations.py:16–31  ·  view source on GitHub ↗

Read the current schema version from the metadata table. Returns: int: The schema version (0 if metadata table doesn't exist, 1 if not set).

(conn: sqlite3.Connection)

Source from the content-addressed store, hash-verified

14
15
16def get_schema_version(conn: sqlite3.Connection) -> int:
17 """Read the current schema version from the metadata table.
18
19 Returns:
20 int: The schema version (0 if metadata table doesn't exist, 1 if not set).
21 """
22 try:
23 row = conn.execute(
24 "SELECT value FROM metadata WHERE key = 'schema_version'"
25 ).fetchone()
26 if row is None:
27 return 1
28 return int(row[0] if isinstance(row, (tuple, list)) else row["value"])
29 except sqlite3.OperationalError:
30 # metadata table doesn't exist
31 return 0
32
33
34def _set_schema_version(conn: sqlite3.Connection, version: int) -> None:

Calls

no outgoing calls