Created
December 7, 2017 13:08
-
-
Save macbre/42194ba776e45b0757c4cfddd3e8f150 to your computer and use it in GitHub Desktop.
Wiki tables cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLUSTER=$1 | |
TABLE_NAME=user | |
echo "Will remove per-wiki '${TABLE_NAME}' tables on '${CLUSTER}' cluster..." | |
WIKICITIES_PARAMS=`dbparams.pl --name wikicities_${CLUSTER} --type=slave` | |
MASTER_PARAMS=`dbparams.pl --name wikicities_${CLUSTER} --type=master` | |
for DBNAME in `mysql $WIKICITIES_PARAMS --batch --disable-column-names -e 'select TABLE_SCHEMA as wiki_db FROM information_schema.TABLES WHERE TABLE_NAME="'${TABLE_NAME}'"'` | |
do | |
mysql $MASTER_PARAMS --verbose -e 'USE '${DBNAME}'; DROP /* SUS-3071 */ TABLE '${TABLE_NAME}';' | |
echo "$DBNAME: dropped" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLUSTER=$1 | |
TABLE_NAME=job | |
echo "Will truncate (if not empty) per-wiki '${TABLE_NAME}' tables on '${CLUSTER}' cluster..." | |
WIKICITIES_PARAMS=`dbparams.pl --name wikicities_${CLUSTER} --type=slave` | |
MASTER_PARAMS=`dbparams.pl --name wikicities_${CLUSTER} --type=master` | |
for DBNAME in `mysql $WIKICITIES_PARAMS --batch --disable-column-names -e 'select TABLE_SCHEMA as wiki_db FROM information_schema.TABLES WHERE TABLE_NAME="'${TABLE_NAME}'" AND TABLE_ROWS > 0'` | |
do | |
mysql $MASTER_PARAMS --verbose -e 'USE '${DBNAME}'; TRUNCATE /* SUS-3471 */ TABLE '${TABLE_NAME}';' | |
echo "$DBNAME: truncated" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment