diff --git a/METdbLoad/sql/mv_mysql.sql b/METdbLoad/sql/mv_mysql.sql index 066948d..e8078f2 100644 --- a/METdbLoad/sql/mv_mysql.sql +++ b/METdbLoad/sql/mv_mysql.sql @@ -2290,12 +2290,12 @@ CREATE TABLE line_data_seeps obs_valid_beg DATETIME, obs_valid_end DATETIME, total INT UNSIGNED, - s12 DOUBLE, - s13 DOUBLE, - s21 DOUBLE, - s23 DOUBLE, - s31 DOUBLE, - s32 DOUBLE, + odfl DOUBLE, + odfh DOUBLE, + olfd DOUBLE, + olfh DOUBLE, + ohfd DOUBLE, + ohfl DOUBLE, pf1 DOUBLE, pf2 DOUBLE, pf3 DOUBLE, diff --git a/METdbLoad/sql/scripts/db_cmds.bash b/METdbLoad/sql/scripts/db_cmds.bash new file mode 100755 index 0000000..6211818 --- /dev/null +++ b/METdbLoad/sql/scripts/db_cmds.bash @@ -0,0 +1,51 @@ +#!/usr/bin/bash + + +echo "" +echo "" +echo "" +echo "*****************" +echo " USAGE" +echo "*****************" +echo "" +echo " ***Run under BASH shell***" +echo " SET the following ENV variables: " +echo " DB_PWD - the password for the mvadmin user" +echo " DBNAME - the name of the database you wish to create/drop/load schema" +echo " MVSCHEMA - the full path and name of the mv_mysql.sql script to load the schema" +echo " Then copy and paste the appropriate command for dropping, creating, or loading the schema after running the following on the command line:" +echo "" +echo " bash db_cmd.bash " +echo "" +echo "*****************" +echo "" +echo "" +echo "" + +echo "" +echo "********" +echo "Command to drop database ${DBNAME} if it exists (or error message if it doesn't exist)..." +echo "********" +echo mysql -u mvadmin -p${DB_PWD} "'drop database" ${DBNAME}"';" + + +echo "" +echo "********" +echo "Command to create database ${DBNAME}..." +echo "********" +echo mysql -u mvadmin -p${DB_PWD} -e "'"create database ${DBNAME}"'"; + +echo "" +echo "********" +echo "Command to grant privileges to ${DBNAME}..." +echo "********" +echo mysql -u mvadmin -p${DB_PWD} -e "\""GRANT INSERT, DELETE, UPDATE, INDEX, DROP ON ${DBNAME}.* to "'"mvuser"'"@"'"%"'" "\"" +echo "" + + +echo "" +echo "********" +echo "Command to load mv_mysql.sql schema ${DBNAME}..." +echo "********" +echo mysql -u mvadmin -p${DB_PWD} ${DBNAME} "<" ${MVSCHEMA} +echo "" diff --git a/METdbLoad/sql/updates/update_for_6_0_beta6.sql b/METdbLoad/sql/updates/update_for_6_0_beta6.sql index 00466bf..c066305 100644 --- a/METdbLoad/sql/updates/update_for_6_0_beta6.sql +++ b/METdbLoad/sql/updates/update_for_6_0_beta6.sql @@ -13,6 +13,15 @@ ALTER TABLE line_data_orank RENAME COLUMN climo_stdev TO obs_climo_stdev | ADD COLUMN fcst_climo_mean DOUBLE | ADD COLUMN fcst_climo_stdev DOUBLE | + +ALTER TABLE line_data_seeps + RENAME COLUMN s12 TO odfl | + RENAME COLUMN s13 TO odfh | + RENAME COLUMN s21 TO olfd | + RENAME COLUMN s23 TO olfh | + RENAME COLUMN s31 TO ohfd | + RENAME COLUMN s32 TO ohfl | + | DELIMITER ; diff --git a/METdbLoad/tests/update_schema_6.0_beta6/Data/total_data.tar b/METdbLoad/tests/update_schema_6.0_beta6/Data/total_data.tar index a330007..92766f1 100644 Binary files a/METdbLoad/tests/update_schema_6.0_beta6/Data/total_data.tar and b/METdbLoad/tests/update_schema_6.0_beta6/Data/total_data.tar differ diff --git a/METdbLoad/tests/update_schema_6.0_beta6/test_schema.py b/METdbLoad/tests/update_schema_6.0_beta6/test_schema.py index d628104..cc06122 100644 --- a/METdbLoad/tests/update_schema_6.0_beta6/test_schema.py +++ b/METdbLoad/tests/update_schema_6.0_beta6/test_schema.py @@ -14,8 +14,8 @@ # Make sure the database name matches with the one you created on the database host -CONST_LOAD_DB_CMD = "use mv_mpr_orank" -TEST_DB = "mv_mpr_orank" +CONST_LOAD_DB_CMD = "use mv_mpr_orank_seeps" +TEST_DB = "mv_mpr_orank_seeps" @pytest.fixture def setup_db(): @@ -76,6 +76,7 @@ def test_db_created(setup_db): finally: setup_db.close() + def test_tables_created(setup_db): # connect to the database and verify the MPR and ORANK tables exist @@ -98,6 +99,7 @@ def test_tables_created(setup_db): finally: setup_db.close() + def test_mpr_columns(setup_db): # log into the database and verify the renamed columns are in the # list_data_mpr database table, the previous/replaced columns do NOT @@ -123,6 +125,7 @@ def test_mpr_columns(setup_db): finally: setup_db.close() + def test_orank_columns(setup_db): # log into the database and verify the renamed and new columns are in the # list_data_orank database table, and the previous/replaced columns no longer @@ -145,3 +148,37 @@ def test_orank_columns(setup_db): finally: setup_db.close() +def test_seeps_columns(setup_db): + # log into the database and verify the renamed SEEPS columns are in the + # list_data_seeps database table, and the previous/replaced columns no longer + # exist. + + try: + with setup_db.cursor() as cursor: + cursor.execute(CONST_LOAD_DB_CMD) + check_columns_exist = "desc line_data_seeps;" + cursor.execute(check_columns_exist) + + # Get all rows + rows = cursor.fetchall() + list_of_rows = [r[0] for r in rows] + + # Verify newly renamed columns exist in the updated data + assert 'odfl' in list_of_rows + assert 'odfh' in list_of_rows + assert 'olfd' in list_of_rows + assert 'olfh' in list_of_rows + assert 'ohfd' in list_of_rows + assert 'ohfl' in list_of_rows + + # Verify that remaining columns are unchanged in the updated data + assert 'pf1' in list_of_rows + assert 'pf2' in list_of_rows + assert 'pf3' in list_of_rows + assert 'pv1' in list_of_rows + assert 'pv2' in list_of_rows + assert 'pv3' in list_of_rows + + finally: + setup_db.close() +