This repository has been 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
Make it easier to use DataGrip w/ Synapse's schema #14982
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4b6471c
Make it easier to use DataGrip w/ Synapse's schema
4035d52
Move into contrib
6c3eb69
Further reduce img size with `pngquant --speed 1`
f8d845a
Update symlinks in schema dump script
c31b24c
Remind myself how to use schema dump script
7cc5052
Explicitly call `poetry run`
71781eb
Changelog
cc35626
Fix bash string suffix test
d383945
Fix symlink generation
a2c6c65
Revert pyproject changes
1f1b5b0
Tweak README phrasing
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 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 @@ | ||
Add a schema dump symlinks inside `contrib`, to make it easier for IDEs to interrogate Synapse's database schema. |
This file contains 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,28 @@ | ||
# Schema symlinks | ||
|
||
This directory contains symlinks to the latest dump of the postgres full schema. This is useful to have, as it allows IDEs to understand our schema and provide autocomplete, linters, inspections, etc. | ||
|
||
In particular, the DataGrip functionality in IntelliJ's products seems to only consider files called `*.sql` when defining a schema from DDL; `*.sql.postgres` will be ignored. To get around this we symlink those files to ones ending in `.sql`. We've chosen to ignore the `.sql.sqlite` schema dumps here, as they're not intended for production use (and are much quicker to test against). | ||
|
||
## Example | ||
![](datagrip-aware-of-schema.png) | ||
|
||
## Caveats | ||
|
||
- Doesn't include temporary tables created ad-hoc by Synapse. | ||
- Postgres only. IDEs will likely be confused by SQLite-specific queries. | ||
- Will not include migrations created after the latest schema dump. | ||
- Symlinks might confuse checkouts on Windows systems. | ||
|
||
## Instructions | ||
|
||
### Jetbrains IDEs with DataGrip plugin | ||
|
||
- View -> Tool Windows -> Database | ||
- `+` Icon -> DDL Data Source | ||
- Pick a name, e.g. `Synapse schema dump` | ||
- Under sources, click `+`. | ||
- Add an entry with Path pointing to this directory, and dialect set to PostgreSQL. | ||
- OK, and OK. | ||
- IDE should now be aware of the schema. | ||
- Try control-clicking on a table name in a bit of SQL e.g. in `_get_forgotten_rooms_for_user_txn`. |
This file contains 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 @@ | ||
../../synapse/storage/schema/common/full_schemas/72/full.sql.postgres |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 @@ | ||
../../synapse/storage/schema/main/full_schemas/72/full.sql.postgres |
This file contains 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 @@ | ||
../../synapse/storage/schema/common/schema_version.sql |
This file contains 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 @@ | ||
../../synapse/storage/schema/state/full_schemas/72/full.sql.postgres |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could symlink each of these individually? That seems like overkill though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my thinking was that this would be good enough 90% of the time (and encourage us to take schema dumps more regularly in the future!)