We get old project, with braindead architecture.
Database structure provides surprises regularly. Yesterday we had a problem with maximum integer value reached at one column.
‘id’ at one table was auto_increment and “INT” not UNSIGNED INT or BIG INT, so after reaching id value 2147483647 application stop working, I change type to UNSIGNED BIGINT.
But Issue to check all similar fields at DB structure occur. How to solve it. We have 300+ tables.
lets select db,table name,column name WITH DATA_TYPE like ‘%int%’ and auto incremented.
I pipe output to file, parse via bash and exec sql for each row.
output looks like:
smi20 ad_model id int smi20 ad_model_filter id int smi20 ad_model_setting id int smi20 ad_model_setting_value id int smi20 ad_model_settings_set id int smi20 ad_preview_page id int smi20 ad_strategy id bigint smi20 alerts id int
How to get values:
Sorry I was in hurry and create Hindu bash code again :(.
for i in `cat ./feelds.txt | awk '{print $2"+"$3"+"$4}'`;
do
res=`echo $i | sed 's/+/ /g'`
words=( $res )
echo "table_name ${words[0]} column_name ${words[1]} column_type ${words[2]} max_value 2 147 483 648"
mysql -u root -pMEGAPASS -h localhost DBNAME -e "select max(${words[1]}) from ${words[0]};"
done
0 Comments.