diff options
author | David Robertson <davidr@element.io> | 2022-09-06 18:21:24 +0100 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2022-09-06 18:28:26 +0100 |
commit | 5452fdc26907dbf909ad65edd3ed0622ac0ad0d8 (patch) | |
tree | a45ca6e8822c2c233d4daab5972704f6f8e73302 | |
parent | Fix db update script invocation during schema dump (diff) | |
download | synapse-github/dmr/cut-schema.tar.xz |
Use .schema to dump from sqlite github/dmr/cut-schema dmr/cut-schema
This has the following effects: - Don't wrap the schema in a transaction - `CREATE VIRTUAL TABLE` for full text search, which means we don't have to do `PRAGMA writable_scshema=...` - Don't insert initial values for stream positions and similarly locked things Both of these seem to better match the sqlite full schema dump we have in the source tree. Also use `--indent` to produce something that's more human readable. ``` $ diff dump/sqlite-{dump,schema}-sorted 6,7d5 < BEGIN TRANSACTION; < COMMIT; 287a286,287 > CREATE VIRTUAL TABLE event_search USING fts4 ( event_id, room_id, sender, key, value ) > CREATE VIRTUAL TABLE user_directory_search USING fts4 ( user_id, value ) 289a290 > /* event_search(event_id,room_id,sender,"key",value) */; 291,300d291 < INSERT INTO appservice_stream_position VALUES('X',0); < INSERT INTO event_push_summary_last_receipt_stream_id VALUES('X',0); < INSERT INTO event_push_summary_stream_ordering VALUES('X',0); < INSERT INTO federation_stream_position VALUES('events',-1,'master'); < INSERT INTO federation_stream_position VALUES('federation',-1,'master'); < INSERT INTO schema_compat_version VALUES('X',72); < INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)VALUES('table','event_search','event_search',0,'CREATE VIRTUAL TABLE event_search USING fts4 ( event_id, room_id, sender, key, value )'); < INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)VALUES('table','user_directory_search','user_directory_search',0,'CREATE VIRTUAL TABLE user_directory_search USING fts4 ( user_id, value )'); < INSERT INTO stats_incremental_position VALUES('X',1); < INSERT INTO user_directory_stream_pos VALUES('X',1); 302,304d292 < PRAGMA foreign_keys=OFF; < PRAGMA writable_schema=OFF; < PRAGMA writable_schema=ON; 307a296 > /* user_directory_search(user_id,value) */; ```
-rwxr-xr-x | scripts-dev/make_full_schema.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts-dev/make_full_schema.sh b/scripts-dev/make_full_schema.sh index 71e914c984..56e8a2527d 100755 --- a/scripts-dev/make_full_schema.sh +++ b/scripts-dev/make_full_schema.sh @@ -185,7 +185,7 @@ sqlite3 "$SQLITE_DB" <<< "$SQL" psql "$POSTGRES_DB_NAME" -w <<< "$SQL" echo "Dumping SQLite3 schema to '$OUTPUT_DIR/$SQLITE_FULL_SCHEMA_OUTPUT_FILE'..." -sqlite3 "$SQLITE_DB" ".dump" > "$OUTPUT_DIR/$SQLITE_FULL_SCHEMA_OUTPUT_FILE" +sqlite3 "$SQLITE_DB" ".schema --indent" > "$OUTPUT_DIR/$SQLITE_FULL_SCHEMA_OUTPUT_FILE" echo "Dumping Postgres schema to '$OUTPUT_DIR/$POSTGRES_FULL_SCHEMA_OUTPUT_FILE'..." pg_dump --format=plain --no-tablespaces --no-acl --no-owner $POSTGRES_DB_NAME | sed -e '/^--/d' -e 's/public\.//g' -e '/^SET /d' -e '/^SELECT /d' > "$OUTPUT_DIR/$POSTGRES_FULL_SCHEMA_OUTPUT_FILE" |