diff --git a/2022/change_change_time_T313070.py b/2022/change_change_time_T313070.py new file mode 100644 index 0000000..91028dc --- /dev/null +++ b/2022/change_change_time_T313070.py @@ -0,0 +1,41 @@ +from auto_schema.schema_change import SchemaChange + +# Copy this file and make adjustments + +# Set to None or 0 to skip downtiming +downtime_hours = 2 +ticket = 'T313070' + +# Don't add set session sql_log_bin=0; +command = """ALTER TABLE /*_*/wb_changes CHANGE change_time change_time BINARY(14) NOT NULL;""" + +# Set this to false if you don't want to run on all dbs +# In that case, you have to specify the db in the command and check function. +all_dbs = True + +# DO NOT FORGET to set the right port if it's not 3306 +# Use None instead of [] to get all direct replicas of master of active dc +replicas = None +section = 's8' + +# The check function must return true if schema change is applied +# or not needed, False otherwise. + +def check(db): + query_res = db.run_sql('desc wb_changes;') + if not query_res: + # Dry run + return True + field_def = query_res.split('change_time')[1].split('\n')[0] + return 'varbinary' not in field_def.lower() + +schema_change = SchemaChange( + replicas=replicas, + section=section, + all_dbs=all_dbs, + check=check, + command=command, + ticket=ticket, + downtime_hours=downtime_hours +) +schema_change.run()