@@ -32,13 +32,18 @@ def _get_inspector() -> sa.engine.reflection.Inspector:
3232 return inspector
3333
3434
35- def _add_column (table : str , value : str , column_name : str ) -> None :
35+ def _add_column (
36+ table : str ,
37+ column_name : str ,
38+ type_ : sa .types .TypeEngine ,
39+ value : str | None = None ,
40+ ) -> None :
3641 if not _column_exists (table , column_name ):
3742 op .add_column (
3843 table ,
3944 sa .Column (
4045 column_name ,
41- sa . String ( 128 ) ,
46+ type_ ,
4247 nullable = False ,
4348 server_default = value ,
4449 ),
@@ -107,8 +112,8 @@ def upgrade() -> None:
107112 )
108113
109114 if _table_exists (tasks_table ):
110- _add_column (tasks_table , owner , ' owner' )
111- _add_column (tasks_table , '0 ' , 'last_updated' )
115+ _add_column (tasks_table , ' owner' , sa . String ( 128 ), owner )
116+ _add_column (tasks_table , 'last_updated ' , sa . DateTime ( timezone = True ) )
112117 _add_index (
113118 tasks_table ,
114119 f'idx_{ tasks_table } _owner_last_updated' ,
@@ -120,7 +125,9 @@ def upgrade() -> None:
120125 )
121126
122127 if _table_exists (push_notification_configs_table ):
123- _add_column (push_notification_configs_table , owner , 'owner' )
128+ _add_column (
129+ push_notification_configs_table , 'owner' , sa .String (128 ), owner
130+ )
124131 else :
125132 logging .warning (
126133 f"Table '{ push_notification_configs_table } ' does not exist. Skipping upgrade for this table."
0 commit comments