@@ -141,10 +141,6 @@ class Base(DeclarativeBase):
141141
142142
143143# TaskMixin that can be used with any table name
144- _task_model_cache : dict [tuple [str , type ], type ] = {}
145- _push_notification_config_model_cache : dict [tuple [str , type ], type ] = {}
146-
147-
148144class TaskMixin :
149145 """Mixin providing standard task columns with proper type handling."""
150146
@@ -220,9 +216,6 @@ def create_task_model(
220216
221217 TaskModel = create_task_model('tasks', MyBase)
222218 """
223- cache_key = (table_name , base )
224- if cache_key in _task_model_cache :
225- return _task_model_cache [cache_key ]
226219
227220 class TaskModel (TaskMixin , base ): # type: ignore
228221 __tablename__ = table_name
@@ -239,10 +232,16 @@ def __repr__(self) -> str:
239232 TaskModel .__name__ = f'TaskModel_{ table_name } '
240233 TaskModel .__qualname__ = f'TaskModel_{ table_name } '
241234
242- _task_model_cache [cache_key ] = TaskModel
243235 return TaskModel
244236
245237
238+ # Default TaskModel for backward compatibility
239+ class TaskModel (TaskMixin , Base ):
240+ """Default task model with standard table name."""
241+
242+ __tablename__ = 'tasks'
243+
244+
246245# PushNotificationConfigMixin that can be used with any table name
247246class PushNotificationConfigMixin :
248247 """Mixin providing standard push notification config columns."""
@@ -266,9 +265,6 @@ def create_push_notification_config_model(
266265 base : type [DeclarativeBase ] = Base ,
267266) -> type :
268267 """Create a PushNotificationConfigModel class with a configurable table name."""
269- cache_key = (table_name , base )
270- if cache_key in _push_notification_config_model_cache :
271- return _push_notification_config_model_cache [cache_key ]
272268
273269 class PushNotificationConfigModel (PushNotificationConfigMixin , base ): # type: ignore
274270 __tablename__ = table_name
@@ -277,19 +273,22 @@ class PushNotificationConfigModel(PushNotificationConfigMixin, base): # type: i
277273 def __repr__ (self ) -> str :
278274 """Return a string representation of the push notification config."""
279275 return (
280- f'<PushNotificationConfigModel[{ table_name } ](task_id=" { self . task_id } ", '
281- f'config_id="{ self .config_id } ")>'
276+ f'<PushNotificationConfigModel[{ table_name } ]('
277+ f'task_id=" { self . task_id } ", config_id="{ self .config_id } ")>'
282278 )
283279
284- # Set a dynamic name for better debugging
285280 PushNotificationConfigModel .__name__ = (
286281 f'PushNotificationConfigModel_{ table_name } '
287282 )
288283 PushNotificationConfigModel .__qualname__ = (
289284 f'PushNotificationConfigModel_{ table_name } '
290285 )
291286
292- _push_notification_config_model_cache [cache_key ] = (
293- PushNotificationConfigModel
294- )
295287 return PushNotificationConfigModel
288+
289+
290+ # Default PushNotificationConfigModel for backward compatibility
291+ class PushNotificationConfigModel (PushNotificationConfigMixin , Base ):
292+ """Default push notification config model with standard table name."""
293+
294+ __tablename__ = 'push_notification_configs'
0 commit comments