Changeset 25154 in main
- Timestamp:
- 04/29/22 18:00:41 (3 months ago)
- Location:
- trunk/db/src/main/scripts/mysql/migrate
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/db/src/main/scripts/mysql/migrate/11_data-dataset_record.sql
r25095 r25154 166 166 /* check DSRs that don't have a dataset. */ 167 167 select * from TMP_DATASET_RECORD where DATASET_NAME is null; 168 ==> 400rows168 ==> 224 rows 169 169 170 170 /* IVV names that don't match */ … … 180 180 and INDICATOR_VIEW_NAME not in (select INDICATOR_VIEW_NAME from TMP_INDICATOR_VIEW_DATASET) 181 181 ; 182 ==> removed the above 400recs182 ==> removed the above 224 recs 183 183 184 184 … … 427 427 and ((LABEL is null) or (LABEL <= "")) 428 428 ; 429 ==> 11 75429 ==> 1190 430 430 431 431 delete from DATASET_RECORD … … 524 524 525 525 Can do a before update and after to see the dimension1or2 value change. 526 select * from ibisph.DIMENSION_TO_DATASET;526 select * from DIMENSION_TO_DATASET; 527 527 where DATASET_NAME = 'AlcoholDrinkDriveAdult.PctDrinkDrive.BRFSS' 528 528 */ 529 select * from ibisph.DIMENSION_TO_DATASET dtd529 select * from DIMENSION_TO_DATASET dtd 530 530 where DIMENSION_USAGE = 'dimension1' 531 531 and DIMENSION_NAME in 532 532 (select dr1.DIMENSION_1_NAME 533 from ibisph.DATASET_RECORD dr1533 from DATASET_RECORD dr1 534 534 where dr1.DATASET_NAME = dtd.DATASET_NAME 535 and dr1.DIMENSION_1_NAME in (select DIMENSION_2_NAME from ibisph.DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME)535 and dr1.DIMENSION_1_NAME in (select DIMENSION_2_NAME from DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME) 536 536 ) 537 537 ; … … 556 556 */ 557 557 select count(*) 558 from ibisph.DATASET_RECORD dr1559 where dr1.DIMENSION_2_NAME in (select DIMENSION_1_NAME from ibisph.DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME)558 from DATASET_RECORD dr1 559 where dr1.DIMENSION_2_NAME in (select DIMENSION_1_NAME from DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME) 560 560 order by dr1.DATASET_NAME, dr1.DIMENSION_1_NAME, dr1.DIMENSION_1_VALUE, dr1.DIMENSION_2_NAME, dr1.DIMENSION_2_VALUE 561 561 ; 562 562 563 563 select count(*) 564 from ibisph.DATASET_RECORD dr1565 where dr1.DIMENSION_1_NAME in (select DIMENSION_2_NAME from ibisph.DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME)564 from DATASET_RECORD dr1 565 where dr1.DIMENSION_1_NAME in (select DIMENSION_2_NAME from DATASET_RECORD dr2 where dr2.DATASET_NAME = dr1.DATASET_NAME) 566 566 order by dr1.DATASET_NAME, dr1.DIMENSION_1_NAME, dr1.DIMENSION_1_VALUE, dr1.DIMENSION_2_NAME, dr1.DIMENSION_2_VALUE 567 567 ; … … 637 637 638 638 639 /* 639 640 issue appears to be dup keys for different IPVs with different measure values... 640 641 */ 641 642 select ivv.INDICATOR_VIEW_NAME, 642 643 ivv.DIMENSION_1_NAME, ivv.DIMENSION_1_VALUE, … … 673 674 674 675 676 /* test any datasets that don't have any records? */ 677 select * from DATASET 678 where NAME not in (select DATASET_NAME from DATASET_RECORD) 679 ; 680 681 /* test IPs that do NOT have a dataset */ 682 select NAME from INDICATOR 683 where NAME not in (select INDICATOR_NAME from DATASET) 684 ; 685 686 /* show DSR record count by dataset */ 687 select DATASET_NAME, count(DATASET_NAME) 688 from DATASET_RECORD 689 group by DATASET_NAME 690 ; 691 692 /* show IVVs count by IV */ 693 select INDICATOR_VIEW_NAME, count(INDICATOR_VIEW_NAME) 694 from INDICATOR_VIEW_VALUE 695 group by INDICATOR_VIEW_NAME 696 ; 697 675 698 676 699 … … 719 742 limit 5000 720 743 ; 721 ==> 3021744 ==> 2451 722 745 723 746 … … 732 755 ) as a 733 756 ; 734 ==> 757 ==> 114 735 758 736 759 will need a mapping file for source IP with a new name and all the assoc -
trunk/db/src/main/scripts/mysql/migrate/12_data-dataset_record_ancillary_value.sql
r24731 r25154 1 use ibisph;2 3 1 /* This script relies on the TMP_DATASET_RECORD table created and updated via 4 2 the data-dataset_record script. -
trunk/db/src/main/scripts/mysql/migrate/2_data-ip_ipv_rename.sql
r25052 r25154 35 35 36 36 37 update INDICATOR_VIEW set NAME = ifnull( (select NAME3 from TMP_IP23NAME_IP3NAME where NAME2 = NAME), NAME); 38 update INDICATOR_VIEW set INDICATOR_NAME = ifnull( (select NAME3 from TMP_IP23NAME_IP3NAME where NAME2 = INDICATOR_NAME), INDICATOR_NAME); 37 /* set IV NAME and assoc IP NAME */ 38 update INDICATOR_VIEW iv 39 inner join TMP_IP23NAME_IP3NAME t on iv.NAME = t.NAME2 40 set 41 iv.NAME = t.NAME3, 42 iv.INDICATOR_NAME = substring_index(t.NAME3, '.', 1) 43 ; 39 44 40 45 … … 48 53 update DATA_SOURCE_TO_INDICATOR_VIEW set INDICATOR_VIEW_NAME = ifnull( (select NAME3 from TMP_IP23NAME_IP3NAME where NAME2 = INDICATOR_VIEW_NAME), INDICATOR_VIEW_NAME); 49 54 50 /* test */ 55 56 /* IMPORTANT TEST: The split hasn't happened yet so every IV MUST have a DS. */ 57 select NAME from INDICATOR_VIEW 58 where NAME not in (select INDICATOR_VIEW_NAME from DATA_SOURCE_TO_INDICATOR_VIEW); 59 60 /* unused datasources but might be needed for the split. */ 51 61 select * from DATA_SOURCE_TO_INDICATOR_VIEW 52 62 where INDICATOR_VIEW_NAME not in (select NAME from INDICATOR_VIEW); 53 63 64 /* Misc queries that might be ran for basic info: 65 select count(*) from DATA_SOURCE; 66 select count(*) from DATA_SOURCE_TO_INDICATOR_VIEW; 67 54 68 select * from DATA_SOURCE_TO_INDICATOR_VIEW 55 69 where INDICATOR_VIEW_NAME not in (select distinct(INDICATOR_VIEW_NAME) from INDICATOR_VIEW_VALUE); 56 70 */ 57 71 58 72 -
trunk/db/src/main/scripts/mysql/migrate/3_data-ip_ipv_copy.sql
r25153 r25154 1 /* Splits / creates new IPs AND IPVs based on Kim's TMP_ SPLIT_IP_IPV table.1 /* Splits / creates new IPs AND IPVs based on Kim's TMP_COPY_IP_IPV table. 2 2 NOTE: temp table needs to contain the new IP and IPV names. 3 3 … … 27 27 NOTE, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE, MODIFIED_DESCRIPTION 28 28 ) 29 select t.NEW_ IP_NAME, DESCRIPTION, DEFAULT_INDICATOR_VIEW_NAME,29 select t.NEW_NAME, DESCRIPTION, DEFAULT_INDICATOR_VIEW_NAME, 30 30 TITLE, CONCISE_TITLE, 31 31 DEFINITION, NUMERATOR, DENOMINATOR, DATA_NOTE, DATA_ISSUES, DATA_AS_OF_DATE, … … 36 36 DEMOGRAPHIC_FLAG, NOT_SELECTABLE_FLAG, FOOTNOTE_REFERENCES, 37 37 NOTE, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE, MODIFIED_DESCRIPTION 38 from INDICATOR i, TMP_SPLIT_IP_IPV t 39 where i.NAME = t.SOURCE_IP_NAME 40 and t.SOURCE_IP_NAME != t.NEW_IP_NAME 41 and t.NEW_IP_NAME 42 not in (select NAME from INDICATOR) 38 from INDICATOR i, TMP_COPY_IP_IPV t 39 where i.NAME = t.SOURCE_NAME 40 and t.NEW_NAME not in (select NAME from INDICATOR) 41 group by t.NEW_NAME 43 42 ; 44 43 45 44 insert into INDICATOR_TO_INDICATOR (INDICATOR_NAME, RELATED_INDICATOR_NAME, RELATION_NAME) 46 select t.NEW_IP_NAME, RELATED_INDICATOR_NAME, RELATION_NAME 47 from INDICATOR_TO_INDICATOR iti, TMP_SPLIT_IP_IPV t 48 where iti.INDICATOR_NAME = t.SOURCE_IP_NAME 49 and t.SOURCE_IP_NAME != t.NEW_IP_NAME 45 select t.NEW_NAME, RELATED_INDICATOR_NAME, RELATION_NAME 46 from INDICATOR_TO_INDICATOR iti, TMP_COPY_IP_IPV t 47 where iti.INDICATOR_NAME = t.SOURCE_NAME 50 48 and not exists 51 49 ( 52 50 select 1 from INDICATOR_TO_INDICATOR iti2 53 where iti2.INDICATOR_NAME = t.NEW_ IP_NAME51 where iti2.INDICATOR_NAME = t.NEW_NAME 54 52 and iti2.RELATED_INDICATOR_NAME = iti.RELATED_INDICATOR_NAME 55 53 and iti2.RELATION_NAME = iti.RELATION_NAME 56 54 ) 55 group by t.NEW_NAME 57 56 ; 58 57 59 58 insert into INDICATOR_TO_RELATION (INDICATOR_NAME, RELATION_NAME, TEXT) 60 select t.NEW_IP_NAME, RELATION_NAME, TEXT 61 from INDICATOR_TO_RELATION itr, TMP_SPLIT_IP_IPV t 62 where itr.INDICATOR_NAME = t.SOURCE_IP_NAME 63 and t.SOURCE_IP_NAME != t.NEW_IP_NAME 59 select t.NEW_NAME, RELATION_NAME, TEXT 60 from INDICATOR_TO_RELATION itr, TMP_COPY_IP_IPV t 61 where itr.INDICATOR_NAME = t.SOURCE_NAME 64 62 and not exists 65 63 ( 66 64 select 1 from INDICATOR_TO_RELATION itr2 67 where itr2.INDICATOR_NAME = t.NEW_ IP_NAME65 where itr2.INDICATOR_NAME = t.NEW_NAME 68 66 and itr2.RELATION_NAME = itr.RELATION_NAME 69 67 ) 68 group by t.NEW_NAME 70 69 ; 71 70 … … 74 73 INDICATOR_NAME, INDICATOR_SET_NAME, SORT_ORDER 75 74 ) 76 select t.NEW_IP_NAME, itis.INDICATOR_SET_NAME, itis.SORT_ORDER 77 from INDICATOR_TO_INDICATOR_SET itis, TMP_SPLIT_IP_IPV t 78 where itis.INDICATOR_NAME = t.SOURCE_IP_NAME 79 and t.SOURCE_IP_NAME != t.NEW_IP_NAME 75 select t.NEW_NAME, itis.INDICATOR_SET_NAME, itis.SORT_ORDER 76 from INDICATOR_TO_INDICATOR_SET itis, TMP_COPY_IP_IPV t 77 where itis.INDICATOR_NAME = t.SOURCE_NAME 80 78 and not exists 81 79 ( 82 80 select 1 from INDICATOR_TO_INDICATOR_SET itis2 83 where itis2.INDICATOR_NAME = t.NEW_ IP_NAME81 where itis2.INDICATOR_NAME = t.NEW_NAME 84 82 and itis2.INDICATOR_SET_NAME = itis.INDICATOR_SET_NAME 85 83 ) 84 group by t.NEW_NAME 86 85 ; 87 86 88 87 insert into USER_TO_INDICATOR (INDICATOR_NAME, USER_ID) 89 select t.NEW_IP_NAME, USER_ID 90 from USER_TO_INDICATOR uti, TMP_SPLIT_IP_IPV t 91 where uti.INDICATOR_NAME = t.SOURCE_IP_NAME 92 and t.SOURCE_IP_NAME != t.NEW_IP_NAME 88 select t.NEW_NAME, USER_ID 89 from USER_TO_INDICATOR uti, TMP_COPY_IP_IPV t 90 where uti.INDICATOR_NAME = t.SOURCE_NAME 93 91 and not exists 94 92 ( 95 93 select 1 from USER_TO_INDICATOR uti2 96 where uti2.INDICATOR_NAME = t.NEW_ IP_NAME94 where uti2.INDICATOR_NAME = t.NEW_NAME 97 95 and uti2.USER_ID = uti.USER_ID 98 96 ) 97 group by t.NEW_NAME 99 98 ; 100 99 … … 119 118 NOTE, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE, MODIFIED_DESCRIPTION 120 119 ) 121 select t.NEW_ IPV_NAME, t.NEW_IP_NAME,120 select t.NEW_NAME, substring_index(t.NEW_NAME, '.', 1), 122 121 DESCRIPTION, TITLE, SUB_TITLE, 123 122 PERIOD_TITLE, Y_TITLE, … … 134 133 VIEW_TEMPLATE_NAME, 135 134 NOTE, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE, MODIFIED_DESCRIPTION 136 from INDICATOR_VIEW iv, TMP_ SPLIT_IP_IPV t137 where iv.NAME = t.SOURCE_ IPV_NAME138 and t.NEW_ IPV_NAME not in (select NAME from INDICATOR_VIEW)135 from INDICATOR_VIEW iv, TMP_COPY_IP_IPV t 136 where iv.NAME = t.SOURCE_NAME 137 and t.NEW_NAME not in (select NAME from INDICATOR_VIEW) 139 138 ; 140 139 141 140 142 141 insert into DATA_SOURCE_TO_INDICATOR_VIEW (INDICATOR_VIEW_NAME, DATA_SOURCE_NAME, SORT_ORDER) 143 select t.NEW_ IPV_NAME, DATA_SOURCE_NAME, SORT_ORDER144 from DATA_SOURCE_TO_INDICATOR_VIEW dstiv, TMP_ SPLIT_IP_IPV t145 where dstiv.INDICATOR_VIEW_NAME = t.SOURCE_ IPV_NAME142 select t.NEW_NAME, DATA_SOURCE_NAME, SORT_ORDER 143 from DATA_SOURCE_TO_INDICATOR_VIEW dstiv, TMP_COPY_IP_IPV t 144 where dstiv.INDICATOR_VIEW_NAME = t.SOURCE_NAME 146 145 and not exists 147 146 ( 148 147 select 1 from DATA_SOURCE_TO_INDICATOR_VIEW dstiv2 149 where dstiv2.INDICATOR_VIEW_NAME = t.NEW_ IPV_NAME148 where dstiv2.INDICATOR_VIEW_NAME = t.NEW_NAME 150 149 and dstiv2.DATA_SOURCE_NAME = dstiv.DATA_SOURCE_NAME 151 150 ) 152 151 ; 152 153 /* IMPORTANT TEST: Every IV MUST have a DS. */ 154 select NAME from INDICATOR_VIEW 155 where NAME not in (select INDICATOR_VIEW_NAME from DATA_SOURCE_TO_INDICATOR_VIEW); 156 157 /* Unused datasources */ 158 select * from DATA_SOURCE_TO_INDICATOR_VIEW 159 where INDICATOR_VIEW_NAME not in (select NAME from INDICATOR_VIEW); 160 153 161 154 162 … … 165 173 NOTE, ACTIVE_FLAG 166 174 ) 167 select t.NEW_ IPV_NAME,175 select t.NEW_NAME, 168 176 DATASET_SERIES_NAME, DATASET_CATEGORY_NAME, 169 177 DATASET_SERIES_VALUE, DATASET_CATEGORY_VALUE, … … 174 182 NUMERATOR, DENOMINATOR, LABEL, 175 183 NOTE, ACTIVE_FLAG 176 from INDICATOR_VIEW_VALUE ivv, TMP_ SPLIT_IP_IPV t177 where ivv.INDICATOR_VIEW_NAME = t.SOURCE_ IPV_NAME184 from INDICATOR_VIEW_VALUE ivv, TMP_COPY_IP_IPV t 185 where ivv.INDICATOR_VIEW_NAME = t.SOURCE_NAME 178 186 and not exists 179 187 ( 180 188 select 1 from INDICATOR_VIEW_VALUE ivv2 181 where ivv2.INDICATOR_VIEW_NAME = t.NEW_ IPV_NAME189 where ivv2.INDICATOR_VIEW_NAME = t.NEW_NAME 182 190 and ivv2.DATASET_CATEGORY_NAME = ivv.DATASET_CATEGORY_NAME 183 191 and ivv2.DATASET_CATEGORY_VALUE = ivv.DATASET_CATEGORY_VALUE -
trunk/db/src/main/scripts/mysql/migrate/4_data-iv_misc.sql
r25153 r25154 7 7 update INDICATOR_VIEW set MEASURE_TITLE_OVERRIDE = (select MEASURE_TITLE_OVERRIDE from TMP_IPV_MEASURE where IPV_NAME3 = NAME); 8 8 9 10 11 /* add the default view template and set all IPV's to use the default template. */ 12 insert into VIEW_TEMPLATE(NAME, TITLE, DESCRIPTION, VIEW_TYPE, FILEPATH_AND_NAME, SORT_ORDER, ACTIVE_FLAG) 13 values ('IndicatorViewDefault', 'Default Indicator View', 'Default indicator view XSLT', 'INDICATOR_VIEW', 'html/indicator/profile/view/ViewPage.xslt', 1, 'x') 14 ; 15 16 update INDICATOR_VIEW set VIEW_TEMPLATE_NAME = 'IndicatorViewDefault'; 17 9 18 /*------------------------------ END OF FILE ------------------------------*/ -
trunk/db/src/main/scripts/mysql/migrate/5_data-data_source_to_ipv.sql
r25052 r25154 29 29 30 30 31 /* IMPORTANT TESTS: Make sure all IV's have valid DS */ 31 32 select * from DATA_SOURCE_TO_INDICATOR_VIEW 32 33 where SORT_ORDER is null … … 34 35 or DATA_SOURCE_NAME = 'NO DS3 NAME' 35 36 ; 36 delete from DATA_SOURCE_TO_INDICATOR_VIEW37 where SORT_ORDER is null38 or SORT_ORDER = -939 or DATA_SOURCE_NAME = 'NO DS3 NAME'40 ;41 37 42 43 /* IMPORTANT TEST: Need to see IPV's that don't have a data source */44 38 select * from INDICATOR_VIEW 45 39 where NAME not in (select INDICATOR_VIEW_NAME from DATA_SOURCE_TO_INDICATOR_VIEW) 46 40 ; 41 47 42 48 43 /* TEST AND REMOVE IPV DSs that do not match / REMOVE ORPHANDED DATASOURCES. */ … … 53 48 delete from DATA_SOURCE_TO_INDICATOR_VIEW where DATA_SOURCE_NAME not in (select NAME from DATA_SOURCE) or DATA_SOURCE_NAME is null; 54 49 55 /* repeat the tests to make sure counts match */ 50 51 /* Sanity checks. Extra DS to IVs no IV name match, IV's that don't have a DS */ 56 52 select count(*) from DATA_SOURCE_TO_INDICATOR_VIEW; 57 53 select count(*) from DATA_SOURCE_TO_INDICATOR_VIEW where INDICATOR_VIEW_NAME not in (select distinct NAME from INDICATOR_VIEW) or INDICATOR_VIEW_NAME is null; -
trunk/db/src/main/scripts/mysql/migrate/tab_c-tmp.sql
r25056 r25154 20 20 21 21 22 /* Used to split IP and IPVs. Since IP and IPV names are unique script uses 23 the same table for both split opertations. 24 all NAMEs are v3 names. 22 /* Used to copy/split IP and IPVs. Since IP and IPV names are unique script 23 uses the same table for both copy opertations. All NAMEs are v3 names. 25 24 */ 26 drop table if exists TMP_SPLIT_IP_IPV; 27 create table if not exists TMP_SPLIT_IP_IPV ( 28 SOURCE_IP_NAME varchar (100) not null, 29 SOURCE_IPV_NAME varchar (100) not null, 30 NEW_IP_NAME varchar (100) not null, 31 NEW_IPV_NAME varchar (100) not null, 32 constraint TMP_SPLIT_IP_IPV_PK 33 primary key (SOURCE_IPV_NAME, NEW_IPV_NAME) 25 drop table if exists TMP_COPY_IP_IPV; 26 create table if not exists TMP_COPY_IP_IPV ( 27 SOURCE_NAME varchar (100) not null, 28 NEW_NAME varchar (100) not null, 29 constraint TMP_COPY_IP_IPV_PK 30 primary key (SOURCE_NAME, NEW_NAME) 34 31 ); 35 32 -
trunk/db/src/main/scripts/mysql/migrate/update.sql
r25095 r25154 77 77 - Processes all assoc intersection tables etc. 78 78 79 3.3) Split/createnew IP and IPV records (script 3).80 - Split/create new IP/IPVbased on temp table.79 3.3) Create/copy new IP and IPV records (script 3). 80 - Create new IP/IPV record copy based on temp table. 81 81 - Processes all assoc intersection tables etc. 82 82 … … 177 177 /* ---------------- Step 3.x - Run Migration Scripts - Get DB from Kim */ 178 178 1_data-cleanup.sql /* Rerun basic orphaned records cleanup and few misc updates. */ 179 2_data-ip_ipv_rename.sql 180 3_data-ip_ipv_ split.sql179 2_data-ip_ipv_rename.sql /* rename IP and IPVs with assoc intersection records */ 180 3_data-ip_ipv_copy.sql /* create new IP and/or IPVs with assoc intersection records */ 181 181 182 4_data-iv_m easure_name.sql /* Kims mapping with MEASURE_TITLE_OVERRIDE IVN, MN, CMT*/182 4_data-iv_misc.sql /* Kims mapping with MEASURE_TITLE_OVERRIDE IVN, MN, CMT, and View type */ 183 183 6_data-iv_dimensions.sql /* Kim's mapping - will send when finished DSC & S : VALUE to DIM NAME : VALUE */ 184 184 7_data-ivv_dimensions.sql -
trunk/db/src/main/scripts/mysql/migrate/update_cleanup.sql
r25095 r25154 35 35 36 36 drop table if exists TMP_IP23NAME_IP3NAME; 37 drop table if exists TMP_ SPLIT_IP_IPV;37 drop table if exists TMP_COPY_IP_IPV; 38 38 drop table if exists TMP_IPV_MEASURE; 39 39 drop table if exists TMP_DS23NAME_DS3NAME;
Note: See TracChangeset
for help on using the changeset viewer.