@@ -185,6 +185,31 @@ def add_mineru_backend_column():
185185 logger .info ("Column 'mineru_backend' added successfully to data_format_tasks table" )
186186
187187
188+ def add_skip_meta_column ():
189+ """Add skip_meta column to data_format_tasks table"""
190+ try :
191+ logger .info ("Checking if skip_meta column exists in data_format_tasks table..." )
192+ with get_sync_session () as session :
193+ with session .begin ():
194+ result = session .execute (text ("""
195+ SELECT column_name
196+ FROM information_schema.columns
197+ WHERE table_name = 'data_format_tasks' AND column_name = 'skip_meta';
198+ """ ))
199+
200+ if not result .fetchone ():
201+ logger .info ("skip_meta column does not exist, adding it..." )
202+ session .execute (text ("ALTER TABLE data_format_tasks ADD COLUMN skip_meta BOOLEAN DEFAULT FALSE;" ))
203+ logger .info ("Column 'skip_meta' added successfully to data_format_tasks table" )
204+ else :
205+ logger .info ("Column 'skip_meta' already exists in data_format_tasks table" )
206+ except Exception as e :
207+ logger .error (f"Error adding skip_meta column: { e } " )
208+ import traceback
209+ logger .error (traceback .format_exc ())
210+ logger .warning ("Continuing despite error..." )
211+
212+
188213_initialized = False
189214from data_server .database .bean .work import Worker
190215from data_server .job .JobModels import Job
@@ -215,9 +240,28 @@ def create_tables():
215240
216241 _initialized = True
217242
218- add_first_op_column ()
219- add_mineru_api_url_column ()
220- add_mineru_backend_column ()
243+ logger .info ("Starting database column migrations..." )
244+ try :
245+ add_first_op_column ()
246+ except Exception as e :
247+ logger .error (f"Error in add_first_op_column: { e } " )
248+
249+ try :
250+ add_mineru_api_url_column ()
251+ except Exception as e :
252+ logger .error (f"Error in add_mineru_api_url_column: { e } " )
253+
254+ try :
255+ add_mineru_backend_column ()
256+ except Exception as e :
257+ logger .error (f"Error in add_mineru_backend_column: { e } " )
258+
259+ try :
260+ add_skip_meta_column ()
261+ except Exception as e :
262+ logger .error (f"Error in add_skip_meta_column: { e } " )
263+
264+ logger .info ("Database column migrations completed" )
221265def is_table_initialized (table_name : str ) -> bool :
222266 """
223267 Check if a specific table contains any data.
@@ -236,6 +280,12 @@ def initialize_database():
236280 Automatically executes one-time deletion on first startup (tracked in deletion_status table).
237281 This should be called once when the application starts.
238282 """
283+ # Ensure database schema migrations are applied (check on every startup)
284+ try :
285+ add_skip_meta_column ()
286+ except Exception as e :
287+ logger .warning (f"Could not check/add skip_meta column: { e } " )
288+
239289 tables_to_initialize = [
240290 'operator_info' ,
241291 'operator_config' ,
0 commit comments