1
0
Commit Graph

8 Commits

Author SHA1 Message Date
David Robertson
5452fdc269 Use .schema to dump from sqlite
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) */;
```
2022-09-06 18:28:26 +01:00
David Robertson
5f11d0cd7e Fix db update script invocation during schema dump 2022-09-06 17:35:25 +01:00
David Robertson
f3f0ab10fe Move scripts directory inside synapse, exposing as setuptools entry_points (#12118)
* Two scripts are basically entry_points already
* Move and rename scripts/* to synapse/_scripts/*.py
* Delete sync_room_to_group.pl
* Expose entry points in setup.py
* Update linter script and config
* Fixup scripts & docs mentioning scripts that moved

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2022-03-02 13:00:16 +00:00
Nick Barrett
c80878d22a Add --run-background-updates option to update_database script. (#10954)
Signed-off-by: Nick Barrett <nick@beeper.com>
2021-10-06 11:26:18 +01:00
Richard van der Hoff
765473567c Fix make_full_schema to create the db with the right options and user (#9931) 2021-05-07 14:01:57 +01:00
Quentin Gliech
d4c4798a25 Use interpreter from $PATH instead of absolute paths in various scripts using /usr/bin/env (#9689)
On NixOS, `bash` isn't under `/bin/bash` but rather in some directory in `$PATH`. Locally, I've been patching those scripts to make them work.

`/usr/bin/env` seems to be the only [portable way](https://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my) to use binaries from the PATH as interpreters.

Signed-off-by: Quentin Gliech <quentingliech@gmail.com>
2021-03-25 16:53:54 +00:00
Eric Eastwood
80d6dc9783 Remove conflicting sqlite tables that are "reserved" (shadow fts4 tables) (#9003)
Remove conflicting sqlite tables that throw sqlite3.OperationalError: object name reserved for internal use: event_search_content when running the twisted unit tests.

Fix #8996
2021-02-10 20:12:57 +00:00
Andrew Morgan
6676ee9c4a Add dev script to generate full SQL schema files (#6394) 2019-12-11 13:16:01 +00:00