Changeset 1602 for trunk/grails-app


Ignore:
Timestamp:
Mar 8, 2011, 4:08:59 PM (12 years ago)
Author:
work@…
Message:
  • improved database upgrade script
File:
1 edited

Legend:

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

    r1595 r1602  
    3333                changeTemplateTextFieldSignatures(sql, db)      // prevent Grails issue, see http://jira.codehaus.org/browse/GRAILS-6754
    3434                setAssayModuleDefaultValues(sql, db)            // r1490
    35                 dropMappingColumnNameConstraint(sql, db)
     35                dropMappingColumnNameConstraint(sql, db)        // r1525
     36                makeMappingColumnValueNullable(sql, db)         // r1525
    3637                alterStudyAndAssay(sql, db)                                     // r1594
    3738        }
     
    186187
    187188        /**
     189         * the importer requires the value field to be nullable
     190         * @param sql
     191         * @param db
     192         */
     193        public static void makeMappingColumnValueNullable(sql, db) {
     194                // are we running postgreSQL?
     195                if (db == "org.postgresql.Driver") {
     196                        // do we need to perform this update?
     197                        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()
     199
     200                                try {
     201                                        sql.execute("ALTER TABLE mapping_column ALTER COLUMN value DROP NOT NULL")
     202                                } catch (Exception e) {
     203                                        println "makeMappingColumnValueNullable database upgrade failed: " + e.getMessage()
     204                                }
     205                        }
     206                }
     207        }
     208
     209        /**
    188210         * The field study.code has been set to be nullable
    189211         * The field assay.externalAssayId has been removed
Note: See TracChangeset for help on using the changeset viewer.