Skip to content

Commit efd7c74

Browse files
Fix schema init command with SQLite (#302)
* Fix `schema init` command with SQLite * Fix config * Changelog
1 parent 7847207 commit efd7c74

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [unreleased]
4+
5+
### Fixed
6+
7+
* cli: Fixed `schema init` command crash with SQLite databases.
8+
39
## 5.0.0 - 2022-04-08
410

511
This release contains no changes except for the version number.

src/dipdup/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from dipdup.models import Index
4646
from dipdup.models import Schema
4747
from dipdup.utils import iter_files
48-
from dipdup.utils.database import execute_sql_scripts
48+
from dipdup.utils.database import generate_schema
4949
from dipdup.utils.database import set_decimal_context
5050
from dipdup.utils.database import tortoise_wrapper
5151
from dipdup.utils.database import wipe_schema
@@ -397,8 +397,7 @@ async def schema_init(ctx):
397397

398398
# NOTE: It's not necessary a reindex, but it's safe to execute built-in scripts to (re)create views.
399399
conn = get_connection(None)
400-
sql_path = join(dirname(__file__), 'sql', 'on_reindex')
401-
await execute_sql_scripts(conn, sql_path)
400+
await generate_schema(conn, config.database.schema_name)
402401

403402
_logger.info('Schema initialized')
404403

src/dipdup/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class SqliteDatabaseConfig:
7979
kind: Literal['sqlite']
8080
path: str = DEFAULT_SQLITE_PATH
8181

82+
@property
83+
def schema_name(self) -> str:
84+
return 'public'
85+
8286
@cached_property
8387
def connection_string(self) -> str:
8488
return f'{self.kind}://{self.path}'

0 commit comments

Comments
 (0)