Imsmaenum Duplicate fix: Difference between revisions

From IMSMA Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This query should be exported as documentation of the values of the four affected enumcategories:
Duplicate enumvalues cause import issues i.e. empty fields, which are difficult to detect due to there are no error messages
 
This query should be exported as documentation of the values of which inactive enumvalues there before and after upgrade (NAA 2014-10-07):
<pre>
<pre>
SELECT DISTINCT
SELECT DISTINCT
Line 13: Line 15:
"public".imsmaenum
"public".imsmaenum
WHERE
WHERE
"public".imsmaenum.enumcategory = 'Mine Action Activity' OR
"public".imsmaenum.isactive = 'f'
"public".imsmaenum.enumcategory = 'RecommendationType' OR
"public".imsmaenum.enumcategory = 'Worksite' OR
"public".imsmaenum.enumcategory = 'Theme Type'
ORDER BY
ORDER BY
"public".imsmaenum.enumcategory ASC,
"public".imsmaenum.enumcategory ASC,
Line 22: Line 21:
</pre>
</pre>


This query lists the duplicate enumvalues created after the upgrade scripts. Note that there might be more enumcategories than the four above:
<pre>
SELECT
        imsmaenum.enumcategory,
        imsmaenum.enumvalue,
        COUNT (imsmaenum.imsmaenum_guid)
FROM
        imsmaenum
GROUP BY
        imsmaenum.enumcategory,
        imsmaenum.enumvalue
HAVING
        COUNT (
                imsmaenum.imsmaenum_guid
        ) > 1
ORDER BY
        imsmaenum.enumcategory ASC,
        imsmaenum.enumvalue ASC
</pre>
The upgrade scripts wrongly add values to the four enumcategories so duplicates are created. The upgrade scripts also sets some of the existing enumvalues to '''inactive'''. Since all countries may have different duplicates and different options set to inactive there is no fit-all solution and therefore the duplicates enumvalues are best fixed manually. <br/><br/>
[[Image: Duplicate enumvalue1.png | 350px]] <br/>
''Example of enumcategory with duplicates (Query 1)'' <br/> <br/>
[[Image: Duplicate enumvalue2.png | 1000px]] <br/>
# Open table ''imsmaenum'' with Navicat and sort on ''enumcategory''
# Compare the result set from '''before''' the upgrade scripts with current records
# Delete the new rows, in the example created with user ''migration'', by selecting the row and clicking on delete button
# Set ''isactive'' to t (TRUE) on the old rows if the country had them as active in 5.08.04
# Repeat 2- 4 until all are done and run Query 2 as double-check of no duplicates remain.
{{NavBox Upgrade}}
{{NavBox Upgrade}}
[[Category:NoPublic]]
[[Category:NoPublic]]
[[Category:SQL Queries]]
[[Category:SQL Queries]]
[[Category:NAA]]
[[Category:NAA]]

Latest revision as of 13:09, 3 May 2015

Duplicate enumvalues cause import issues i.e. empty fields, which are difficult to detect due to there are no error messages

This query should be exported as documentation of the values of which inactive enumvalues there before and after upgrade (NAA 2014-10-07):

SELECT DISTINCT
"public".imsmaenum.imsmaenum_guid,
"public".imsmaenum.enumcategory,
"public".imsmaenum.enumvalue,
"public".imsmaenum.widgettype,
"public".imsmaenum.seqno,
"public".imsmaenum.dataentrydate,
"public".imsmaenum.dataenterer,
"public".imsmaenum.isactive
FROM
"public".imsmaenum
WHERE
"public".imsmaenum.isactive = 'f'
ORDER BY
"public".imsmaenum.enumcategory ASC,
"public".imsmaenum.enumvalue ASC

{{#switch:|subgroup|child=|none=|#default=

}}{{#if:|}}{{#if:Upgrade Process|<td style="text-align:left;border-left-width:2px;border-left-style:solid;|{{#if:|}}}}{{#if:|{{#if:IMSMA Hub{{#switch:{{#if:|{{{border}}}|child}}|subgroup|child=|none=|#default=

}}{{#ifeq:|Template|{{#ifeq:{{#if:|{{{border}}}|child}}|child||{{#ifeq:{{#if:|{{{border}}}|child}}|subgroup||{{#switch:imsmaenum duplicate fix

|doc
|sandbox
|testcases =
|#default = {{#switch:
 |plainlist
 |hlist
 |hlist hnum
 |hlist vcard
 |vcard hlist = 
 |#default = 
 }}
}}

}}}}}}|}}{{#if:|{{{group2}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list2}}}

}}{{#if:|{{#if:IMSMA Hub{{#switch:{{#if:|{{{border}}}|child}}|subgroup|child=|none=|#default=

}}{{#ifeq:|Template|{{#ifeq:{{#if:|{{{border}}}|child}}|child||{{#ifeq:{{#if:|{{{border}}}|child}}|subgroup||{{#switch:imsmaenum duplicate fix

|doc
|sandbox
|testcases =
|#default = {{#switch:
 |plainlist
 |hlist
 |hlist hnum
 |hlist vcard
 |vcard hlist = 
 |#default = 
 }}
}}

}}}}}}|}}{{#if:|{{{group3}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list3}}}

}}{{#if:|{{#if:|{{{group4}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list4}}}

}}{{#if:|{{#if:|{{{group5}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list5}}}

}}{{#if:|{{#if:|{{{group6}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list6}}}

}}{{#if:|{{#if:|{{{group7}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list7}}}

}}{{#if:|{{#if:|{{{group8}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list8}}}

}}{{#if:|{{#if:|{{{group9}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list9}}}

}}{{#if:|{{#if:|{{{group10}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list10}}}

}}{{#if:|{{#if:|{{{group11}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list11}}}

}}{{#if:|{{#if:|{{{group12}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list12}}}

}}{{#if:|{{#if:|{{{group13}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list13}}}

}}{{#if:|{{#if:|{{{group14}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list14}}}

}}{{#if:|{{#if:|{{{group15}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list15}}}

}}{{#if:|{{#if:|{{{group16}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list16}}}

}}{{#if:|{{#if:|{{{group17}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list17}}}

}}{{#if:|{{#if:|{{{group18}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list18}}}

}}{{#if:|{{#if:|{{{group19}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list19}}}

}}{{#if:|{{#if:|{{{group20}}}<td style="text-align:left;border-left-width:2px;border-left-style:solid;|

{{{list20}}}

}}{{#if:|{{#if:IMSMA Hub{{#switch:{{#if:|{{{border}}}|child}}|subgroup|child=|none=|#default=

}}{{#ifeq:|Template|{{#ifeq:{{#if:|{{{border}}}|child}}|child||{{#ifeq:{{#if:|{{{border}}}|child}}|subgroup||{{#switch:imsmaenum duplicate fix

|doc
|sandbox
|testcases =
|#default = {{#switch:
 |plainlist
 |hlist
 |hlist hnum
 |hlist vcard
 |vcard hlist = 
 |#default = 
 }}
}}

}}}}}}|}}

{{{below}}}

}}{{#switch:|subgroup|child=

|none=|#default=}}{{#ifeq:|Template|{{#ifeq:|child||{{#ifeq:|subgroup||{{#switch:imsmaenum duplicate fix
|doc
|sandbox
|testcases =
|#default = {{#switch:hlist
 |plainlist
 |hlist
 |hlist hnum
 |hlist vcard
 |vcard hlist = 
 |#default = 
 }}
}}

}}}}}}