55import signal
66import subprocess
77import sys
8+ import warnings
89from contextlib import AsyncExitStack
910from contextlib import suppress
1011from dataclasses import dataclass
@@ -350,6 +351,9 @@ async def schema(ctx):
350351@click .pass_context
351352@cli_wrapper
352353async def schema_approve (ctx , hashes : bool ):
354+ if hashes :
355+ warnings .warn ('`--hashes` option is deprecated and has no effect' , DeprecationWarning )
356+
353357 config : DipDupConfig = ctx .obj .config
354358 url = config .database .connection_string
355359 models = f'{ config .package } .models'
@@ -371,22 +375,24 @@ async def schema_approve(ctx, hashes: bool):
371375
372376@schema .command (name = 'wipe' , help = 'Drop all database tables, functions and views' )
373377@click .option ('--immune' , is_flag = True , help = 'Drop immune tables too' )
378+ @click .option ('--force' , is_flag = True , help = 'Skip confirmation prompt' )
374379@click .pass_context
375380@cli_wrapper
376- async def schema_wipe (ctx , immune : bool ):
381+ async def schema_wipe (ctx , immune : bool , force : bool ):
377382 config : DipDupConfig = ctx .obj .config
378383 url = config .database .connection_string
379384 models = f'{ config .package } .models'
380385
381- try :
382- assert sys .__stdin__ .isatty ()
383- click .confirm (f'You\' re about to wipe schema `{ url } `. All indexed data will be irreversibly lost, are you sure?' , abort = True )
384- except AssertionError :
385- click .echo ('Not in a TTY, skipping confirmation' )
386- # FIXME: Can't catch asyncio.CancelledError here
387- except click .Abort :
388- click .echo ('Aborted' )
389- return
386+ if not force :
387+ try :
388+ assert sys .__stdin__ .isatty ()
389+ click .confirm (f'You\' re about to wipe schema `{ url } `. All indexed data will be irreversibly lost, are you sure?' , abort = True )
390+ except AssertionError :
391+ click .echo ('Not in a TTY, skipping confirmation' )
392+ # FIXME: Can't catch asyncio.CancelledError here
393+ except click .Abort :
394+ click .echo ('Aborted' )
395+ return
390396
391397 _logger .info ('Wiping schema `%s`' , url )
392398
0 commit comments