summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
Diffstat (limited to 'installer')
-rwxr-xr-xinstaller/opengnsys_import.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/installer/opengnsys_import.sh b/installer/opengnsys_import.sh
index 2b8ce645..4ac296d1 100755
--- a/installer/opengnsys_import.sh
+++ b/installer/opengnsys_import.sh
@@ -169,6 +169,21 @@ function updateSqlFile()
[ $? != 0 ] && errorAndLog "${FUNCNAME}: Can't create database $AUXCATALOG" && exit 5
mysql --defaults-extra-file=$MYCNF -D "$AUXCATALOG" < $MYSQLFILE &>/dev/null
[ $? != 0 ] && errorAndLog "${FUNCNAME}: Can't import $MYSQLFILE in $AUXCATALOG" && exit 5
+ # Reasignar valores para campos no nulos con nulo por defecto.
+ mysql --defaults-extra-file=$MYCNF -D "$AUXCATALOG" -e \
+ "$(mysql --defaults-extra-file=$MYCNF -Nse "
+SELECT CASE WHEN DATA_TYPE LIKE '%int' THEN
+ CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'ALTER', COLUMN_NAME, 'SET DEFAULT 0;')
+ WHEN DATA_TYPE LIKE '%char' THEN
+ CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'ALTER', COLUMN_NAME, 'SET DEFAULT \'\';')
+ WHEN DATA_TYPE = 'text' THEN
+ CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'MODIFY', COLUMN_NAME, 'TEXT NOT NULL;')
+ END
+ FROM information_schema.columns
+ WHERE TABLE_SCHEMA='$AUXCATALOG'
+ AND IS_NULLABLE='NO'
+ AND COLUMN_DEFAULT IS NULL
+ AND COLUMN_KEY='';")"
for file in $FILES; do
importSqlFile $DBDIR/$file