diff options
-rw-r--r-- | admin/Database/ogAdmBD-1.1.1-1.1.1a.sql | 7 | ||||
-rwxr-xr-x | installer/opengnsys_import.sh | 15 |
2 files changed, 15 insertions, 7 deletions
diff --git a/admin/Database/ogAdmBD-1.1.1-1.1.1a.sql b/admin/Database/ogAdmBD-1.1.1-1.1.1a.sql deleted file mode 100644 index cca72327..00000000 --- a/admin/Database/ogAdmBD-1.1.1-1.1.1a.sql +++ /dev/null @@ -1,7 +0,0 @@ -### Fichero de actualizaciĆ³n de la base de datos. -# OpenGnsys 1.1.1 - OpenGnsys 1.1.1a -#use ogAdmBD - -# Evitar fallo al obtener configuraciĆ³n de ordenador. -ALTER TABLE ordenadores_particiones - ALTER idperfilsoft SET DEFAULT 0; 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 |