77
88from dipdup import spec_version_mapping
99
10+ _tab = '\n \n ' + ('_' * 80 ) + '\n \n '
11+
1012_migration_required_message = """Project migration required!
1113
1214{version_table}
1719See https://baking-bad.org/blog/ for additional release information.
1820"""
1921
22+ _reindexing_required_message = """Reindexing required!
23+
24+ Recent changes in the framework have made it necessary to reindex the project.
25+
26+ 1. Optionally backup a database
27+ 2. Run `dipdup run --reindex`
28+ """
29+
2030_handler_import_message = """Failed to import `{obj}` from `{module}`.
2131
2232Reasons in order of possibility:
5262{error_context}
5363"""
5464
55- _tab = '\n \n ' + ('_' * 80 ) + '\n \n '
56-
5765
5866class DipDupError (ABC , Exception ):
5967 exit_code = 1
@@ -86,12 +94,13 @@ def format_help(self) -> str:
8694
8795
8896class MigrationRequiredError (DipDupError ):
89- """Project and DipDup spec versions don't match """
97+ """Project and DipDup spec versions don't match"""
9098
91- def __init__ (self , ctx , from_ : str , to : str ) -> None :
99+ def __init__ (self , ctx , from_ : str , to : str , reindex : bool = False ) -> None :
92100 super ().__init__ (ctx )
93101 self .from_ = from_
94102 self .to = to
103+ self .reindex = reindex
95104
96105 def format_help (self ) -> str :
97106 version_table = tabulate (
@@ -101,7 +110,16 @@ def format_help(self) -> str:
101110 ],
102111 headers = ['' , 'spec_version' , 'DipDup version' ],
103112 )
104- return _migration_required_message .format (version_table = version_table )
113+ message = _migration_required_message .format (version_table = version_table )
114+ if self .reindex :
115+ message += _tab + _reindexing_required_message
116+ return message
117+
118+
119+ class ReindexingRequiredError (DipDupError ):
120+ """Performed migration requires reindexing"""
121+ def format_help (self ) -> str :
122+ return _reindexing_required_message
105123
106124
107125class HandlerImportError (DipDupError ):
0 commit comments