Magellan Linux

Diff of /alx-src/branches/alx-web-070/scripts/sql-schema/mcore-sql-schema.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8500 by niro, Fri Feb 5 14:11:39 2016 UTC revision 8501 by niro, Fri Feb 5 14:31:53 2016 UTC
# Line 189  sql_modify_column() Line 189  sql_modify_column()
189   local column   local column
190   local autoincrement   local autoincrement
191   local primary   local primary
192     local current_primary
193    
194   table="${TABLE_DEFINITION[0]}"   table="${TABLE_DEFINITION[0]}"
195   count="${#TABLE_DEFINITION[*]}"   count="${#TABLE_DEFINITION[*]}"
# Line 214  sql_modify_column() Line 215  sql_modify_column()
215    
216   if [[ -n ${primary} ]]   if [[ -n ${primary} ]]
217   then   then
218   mysqldo "ALTER TABLE ${MCORE_SQL_DB}.${table} ADD PRIMARY KEY (${primary});" || die "adding primary key to table '${table}'"   # only run this if the primary key is not already the same column
219     i=( $(mysqldo 'SHOW COLUMNS FROM ${MCORE_SQL_DB}.${table} WHERE `Key`="PRI"') )
220     current_primary="${i[0]}"
221     if [[ ${current_primary} != ${primary} ]]
222     then
223     mysqldo "ALTER TABLE ${MCORE_SQL_DB}.${table} ADD PRIMARY KEY (${primary});" || die "adding primary key to table '${table}'"
224     fi
225   fi   fi
226   if [[ -n ${autoincrement} ]]   if [[ -n ${autoincrement} ]]
227   then   then

Legend:
Removed from v.8500  
changed lines
  Added in v.8501