mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-21 01:24:17 -05:00
Add unique constraint on schema_version.lock schema. Use conflict clause in sql.
This commit is contained in:
parent
b4c38738f4
commit
5eefd1f618
@ -645,7 +645,7 @@ def _setup_new_database(cur):
|
||||
cur.executescript(sql_script)
|
||||
|
||||
cur.execute(
|
||||
"INSERT INTO schema_version (version, upgraded)"
|
||||
"INSERT OR REPLACE INTO schema_version (version, upgraded)"
|
||||
" VALUES (?,?)",
|
||||
(max_current_ver, False)
|
||||
)
|
||||
@ -748,7 +748,7 @@ def _upgrade_existing_database(cur, current_version, delta_files, upgraded):
|
||||
)
|
||||
|
||||
cur.execute(
|
||||
"INSERT INTO schema_version (version, upgraded)"
|
||||
"INSERT OR REPLACE INTO schema_version (version, upgraded)"
|
||||
" VALUES (?,?)",
|
||||
(v, True)
|
||||
)
|
||||
@ -803,7 +803,7 @@ def prepare_sqlite3_database(db_conn):
|
||||
|
||||
if row and row[0]:
|
||||
db_conn.execute(
|
||||
"INSERT INTO schema_version (version, upgraded)"
|
||||
"INSERT OR REPLACE INTO schema_version (version, upgraded)"
|
||||
" VALUES (?,?)",
|
||||
(row[0], False)
|
||||
)
|
||||
|
@ -17,7 +17,8 @@ CREATE TABLE IF NOT EXISTS schema_version(
|
||||
Lock char(1) NOT NULL DEFAULT 'X', -- Makes sure this table only has one row.
|
||||
version INTEGER NOT NULL,
|
||||
upgraded BOOL NOT NULL, -- Whether we reached this version from an upgrade or an initial schema.
|
||||
CONSTRAINT schema_version_lock CHECK (Lock='X') ON CONFLICT REPLACE
|
||||
CONSTRAINT schema_version_lock_x CHECK (Lock='X')
|
||||
CONSTRAINT schema_version_lock_uniq UNIQUE (Lock)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS schema_deltas(
|
||||
|
Loading…
Reference in New Issue
Block a user