Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ include = [
{ path = "rust/src/**", format = "sdist" },
]
exclude = [
{ path = "synapse/*.so", format = "sdist"}
{ path = "synapse/*.so", format = "sdist" },
# This contains dev-only symlinks to the latest schema dumps. We don't want people
# to use it when installing.
{ path = "synapse/storage/schema/latest_schema" },
]

build = "build_rust.py"
Expand Down
28 changes: 28 additions & 0 deletions synapse/storage/schema/latest_dump/README.md
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.

I (dmr) use the DataGrip functionality in IntelliJ's paid-for products. It seems to only consider files called `*.sql` when defining a schema from DDL; `*.sql.postgres` wasn't detected for me.

## 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`.
1 change: 1 addition & 0 deletions synapse/storage/schema/latest_dump/common.sql
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions synapse/storage/schema/latest_dump/main.sql
1 change: 1 addition & 0 deletions synapse/storage/schema/latest_dump/schema_version.sql
1 change: 1 addition & 0 deletions synapse/storage/schema/latest_dump/state.sql