Skip to content

Instantly share code, notes, and snippets.

@eastside
Created December 11, 2021 01:32
Show Gist options
  • Save eastside/43c21470ec473089d9dc0ed6aa665a91 to your computer and use it in GitHub Desktop.
Save eastside/43c21470ec473089d9dc0ed6aa665a91 to your computer and use it in GitHub Desktop.
MySQL_Zero_Downtime_SchemaChange.sh
#!/bin/bash
# Example of how to use Percona's online schema changer tool.
# Tips!
# Don't put any semicolons in your schema commmands!
# Separate schema commands by commas; i.e., ADD COLUMN y_id bigint NULL, ADD CONSTRAINT y_fk FOREIGN KEY (y_id) REFERENCES y(y_id)"
# When testing, remove the --execute flag!
# This'll print out lots of rich output too!
pt-online-schema-change \
--execute \
--progress time,1 \
--print \
--recursion-method=none \
-h $HOST \
-u $USER \
--ask-pass \
--alter-foreign-keys-method drop_swap \
--alter "$COMMAND" \
D=heart,t=lambda_invocation_set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment