Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about unusual paths in timescaledb-ha image #858

Merged
merged 4 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

### Fixed


- cli: Added warning for timescaledb-ha users
- demos: Fixed decimal overflow in `demo_uniswap` project.
- evm.node: Fixed incorrect log request parameters.
- evm.subsquid.events: Fixed issue with determining the last level when syncing with node.
Expand Down
27 changes: 27 additions & 0 deletions docs/6.deployment/1.database.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@ Immune tables support for SQLite is experimental and requires `advanced.unsafe_s
Latest PostgreSQL and TimescaleDB versions are recommended due to significant performance improvements in recent releases (see [Feature matrix](https://www.postgresql.org/about/featurematrix/) page).

Usually it's okay to use different database engines for development and production, but be careful with SQL scripts and column types that can behave differently.

## TimescaleDB

TimescaleDB is a PostgreSQL extension that provides time-series data management capabilities. You can use it with DipDup as a drop-in replacement for PostgreSQL.

You can choose `timescale/timescaledb` or `timescale/timescaledb-ha` Docker images when initializing DipDup project.

::banner{type="warning"}
Be careful! Unlike other PostgreSQL images `timescale/timescaledb-ha` uses `/home/postgres/pgdata/data` as a persistent volume.
::

Use SQL scripts in `on_reindex` directory to prepare the database. First, create a hypertable replacing primary key with composite one:

```sql [sql/on_reindex/00_prepare_db.sql]
{{ #include ../src/demo_uniswap/sql/on_reindex/00_prepare_db.sql }}
```

Now you can create a continuous aggregate on top of the hypertable:

```sql [sql/on_reindex/01_create_mv_token_price.sql]
{{ #include ../src/demo_uniswap/sql/on_reindex/01_create_mv_token_price.sql }}
```

For more information visit the official TimescaleDB documentation:

- [Hypertables](https://docs.timescale.com/use-timescale/latest/hypertables/)
- [Continuous aggregates](https://docs.timescale.com/use-timescale/continuous-aggregates/)
3 changes: 2 additions & 1 deletion src/dipdup/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def answers_from_terminal() -> Answers:
),
default=0,
)
if 'timescale-ha' in answers['postgres_image']:
if 'timescaledb-ha' in answers['postgres_image']:
answers['postgres_data_path'] = '/home/postgres/pgdata/data'
echo('`timescaledb-ha` Docker image uses `/home/postgres/pgdata/data` as a data path; generated files were updated accordingly.', fg='yellow')

big_yellow_echo('Miscellaneous tunables; leave default values if unsure')

Expand Down