This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Snapshot schema 72 #13873
Merged
Merged
Snapshot schema 72 #13873
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9acc220
Make DB engines generic over cursors too
7343f23
Add `executescript` to DB engines
8fbea9e
Schema dumper: `full_schema` -> `full_schemas`
736cf30
Fix SQLite dumps: don't use `--indent`
5686864
Postgres dump: don't omit `SELECT setval(...)`
f3b826c
Warn to use old postgres versions
fc0dcd2
Temporarily remove 73-series migrations
e426cd4
Generate dumps of schema 72
29990a9
Revert "Temporarily remove 73-series migrations"
f6b4ba0
Changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Create a new snapshot of the database schema. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
| from synapse.storage.database import LoggingDatabaseConnection | ||
|
|
||
|
|
||
| class Sqlite3Engine(BaseDatabaseEngine[sqlite3.Connection]): | ||
| class Sqlite3Engine(BaseDatabaseEngine[sqlite3.Connection, sqlite3.Cursor]): | ||
| def __init__(self, database_config: Mapping[str, Any]): | ||
| super().__init__(sqlite3, database_config) | ||
|
|
||
|
|
@@ -120,6 +120,25 @@ def attempt_to_set_isolation_level( | |
| # All transactions are SERIALIZABLE by default in sqlite | ||
| pass | ||
|
|
||
| @staticmethod | ||
| def executescript(cursor: sqlite3.Cursor, script: str) -> None: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a lie, because the cursor is actually a I restrained myself from making further type annotations here. |
||
| """Execute a chunk of SQL containing multiple semicolon-delimited statements. | ||
|
|
||
| Python's built-in SQLite driver does not allow you to do this with DBAPI2's | ||
| `execute`: | ||
|
|
||
| > execute() will only execute a single SQL statement. If you try to execute more | ||
| > than one statement with it, it will raise a Warning. Use executescript() if | ||
| > you want to execute multiple SQL statements with one call. | ||
|
|
||
| Though the docs for `executescript` warn: | ||
|
|
||
| > If there is a pending transaction, an implicit COMMIT statement is executed | ||
| > first. No other implicit transaction control is performed; any transaction | ||
| > control must be added to sql_script. | ||
| """ | ||
| cursor.executescript(script) | ||
|
|
||
|
|
||
| # Following functions taken from: https://github.com/coleifer/peewee | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
synapse/storage/schema/common/full_schemas/72/full.sql.postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| CREATE TABLE background_updates ( | ||
| update_name text NOT NULL, | ||
| progress_json text NOT NULL, | ||
| depends_on text, | ||
| ordering integer DEFAULT 0 NOT NULL | ||
| ); | ||
| ALTER TABLE ONLY background_updates | ||
| ADD CONSTRAINT background_updates_uniqueness UNIQUE (update_name); |
6 changes: 6 additions & 0 deletions
6
synapse/storage/schema/common/full_schemas/72/full.sql.sqlite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| CREATE TABLE background_updates ( | ||
| update_name text NOT NULL, | ||
| progress_json text NOT NULL, | ||
| depends_on text, ordering INT NOT NULL DEFAULT 0, | ||
| CONSTRAINT background_updates_uniqueness UNIQUE (update_name) | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.