diff --git a/2024/change_pagelinks_pk.py b/2024/change_pagelinks_pk.py new file mode 100644 index 0000000000000000000000000000000000000000..a270986c98e93cc2027f9cb55185078609b89642 --- /dev/null +++ b/2024/change_pagelinks_pk.py @@ -0,0 +1,36 @@ +from auto_schema.schema_change import SchemaChange + +# Copy this file and make adjustments + +# Set to None or 0 to skip downtiming +downtime_hours = 24 +ticket = 'T352010' + +# Don't add set session sql_log_bin=0; +command = """ALTER TABLE pagelinks DROP PRIMARY KEY, ADD PRIMARY KEY (pl_from, pl_target_id);""" + +# 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 = 's6' + +# The check function must return true if schema change is applied +# or not needed, False otherwise. + +def check(db): + return 'pl_target_id' in db.get_indexes('pagelinks')['PRIMARY']['columns'] + +schema_change = SchemaChange( + replicas=replicas, + section=section, + all_dbs=all_dbs, + check=check, + command=command, + ticket=ticket, + downtime_hours=downtime_hours +) +schema_change.run()