|
15 | 15 | from sentry_sdk.integrations.aiohttp import AioHttpIntegration |
16 | 16 | from sentry_sdk.integrations.logging import LoggingIntegration |
17 | 17 |
|
| 18 | +import dipdup.context as context |
18 | 19 | from dipdup import __spec_version__, __version__, spec_reindex_mapping, spec_version_mapping |
19 | 20 | from dipdup.codegen import DEFAULT_DOCKER_ENV_FILE, DEFAULT_DOCKER_IMAGE, DEFAULT_DOCKER_TAG, DipDupCodeGenerator |
20 | 21 | from dipdup.config import DipDupConfig, LoggingConfig, PostgresDatabaseConfig |
@@ -135,12 +136,15 @@ async def cli(ctx, config: List[str], env_file: List[str], logging_config: str): |
135 | 136 | @cli.command(help='Run indexing') |
136 | 137 | @click.option('--reindex', is_flag=True, help='Drop database and start indexing from scratch') |
137 | 138 | @click.option('--oneshot', is_flag=True, help='Synchronize indexes wia REST and exit without starting WS connection') |
| 139 | +@click.option('--forbid-reindexing', is_flag=True, help='Raise exception instead of truncating database when reindexing is triggered') |
138 | 140 | @click.pass_context |
139 | 141 | @cli_wrapper |
140 | | -async def run(ctx, reindex: bool, oneshot: bool) -> None: |
| 142 | +async def run(ctx, reindex: bool, oneshot: bool, forbid_reindexing: bool) -> None: |
141 | 143 | config: DipDupConfig = ctx.obj.config |
142 | 144 | config.initialize() |
143 | 145 | set_decimal_context(config.package) |
| 146 | + if forbid_reindexing: |
| 147 | + context.forbid_reindexing = True |
144 | 148 | dipdup = DipDup(config) |
145 | 149 | await dipdup.run(reindex, oneshot) |
146 | 150 |
|
|
0 commit comments