Ignore:
Timestamp:
Mar 15, 2011, 2:06:25 PM (9 years ago)
Author:
work@…
Message:
  • added checks to Grom calls if Grom is available so we can uninstall the plugin on packaging time... resolves issue #359
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/DatabaseUpgrade.groovy

    r1602 r1635  
    4747                if (sql.firstRow("SELECT count(*) as total FROM template_field WHERE templatefieldentity='dbnp.studycapturing.Study' AND templatefieldname='Description'").total > 0) {
    4848                        // grom that we are performing the upgrade
    49                         "performing database upgrade: study description".grom()
     49                        if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: study description".grom()
    5050
    5151                        // database upgrade required
     
    9696                        if (sql.firstRow("SELECT count(*) as total FROM information_schema.columns WHERE columns.table_schema::text = 'public'::text AND columns.table_name='study' AND column_name='description' AND data_type != 'text'").total > 0) {
    9797                                // grom that we are performing the upgrade
    98                                 "performing database upgrade: study description to text".grom()
     98                                if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: study description to text".grom()
    9999
    100100                                // database upgrade required
     
    121121                        sql.eachRow("SELECT columns.table_name as tablename FROM information_schema.columns WHERE columns.table_schema::text = 'public'::text AND column_name='template_text_fields_elt' AND data_type != 'text';")
    122122                                { row ->
    123                                         "performing database upgrade: ${row.tablename} template_text_fields_string/elt to text".grom()
     123                                        if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: ${row.tablename} template_text_fields_string/elt to text".grom()
    124124                                        try {
    125125                                                // change the datatype of text fields to text
     
    147147                        (sql.firstRow("SELECT * FROM assay_module WHERE notify IS NULL") || sql.firstRow("SELECT * FROM assay_module WHERE open_in_frame IS NULL"))
    148148                ) {
    149                         "performing database upgrade: assay_module default values for boolean fields".grom()
     149                        if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: assay_module default values for boolean fields".grom()
    150150
    151151                        try {
     
    175175                if (db == "org.postgresql.Driver") {
    176176                        if (sql.firstRow("SELECT * FROM pg_constraint WHERE contype='mapping_column_name_key'")) {
    177                                 "performing database upgrade: mapping column name constraint".grom()
     177                                if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: mapping column name constraint".grom()
    178178                                try {
    179179                                        // Check if constraint still exists
     
    196196                        // do we need to perform this update?
    197197                        if (sql.firstRow("SELECT * FROM information_schema.columns WHERE columns.table_name='mapping_column' AND columns.column_name='value' AND is_nullable='NO'")) {
    198                                 "performing database upgrade: making mapping_column::value nullable".grom()
     198                                if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: making mapping_column::value nullable".grom()
    199199
    200200                                try {
     
    220220                        // see if table assay contains a column external_assayid
    221221                        if (sql.firstRow("SELECT * FROM information_schema.columns WHERE columns.table_name='assay' AND columns.column_name='external_assayid'")) {
    222                                 "performing database upgrade: dropping column 'external_assayid' from table 'assay'".grom()
     222                                if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: dropping column 'external_assayid' from table 'assay'".grom()
    223223
    224224                                try {
     
    233233                        // see if table study contains a column code which is not nullable
    234234                        if (sql.firstRow("SELECT * FROM information_schema.columns WHERE columns.table_name='study' AND columns.column_name='code' AND is_nullable='NO'")) {
    235                                 "performing database upgrade: dropping column 'code' from table 'study'".grom()
     235                                if (String.metaClass.getMetaMethod("grom")) "performing database upgrade: dropping column 'code' from table 'study'".grom()
    236236
    237237                                try {
     
    245245                        // Load all studies and save them again. This prevents errors on saving later
    246246                        if (updated) {
    247                                 "re-saving studies...".grom()
     247                                if (String.metaClass.getMetaMethod("grom")) "re-saving studies...".grom()
    248248
    249249                                Study.list().each { study ->
    250                                         "re-saving study: ${study}".grom()
     250                                        if (String.metaClass.getMetaMethod("grom")) "re-saving study: ${study}".grom()
    251251                                        study.save()
    252252                                }
Note: See TracChangeset for help on using the changeset viewer.