Project

General

Profile

Revision 870bdcfa

ID870bdcfa2c6d2c6575ae87c56c9b9b2a17aa6745
Parent 85fe352f
Child e82fdff4

Added by Andreas Müller over 3 years ago

fix #7468 fix update script for mediaCreated in PostGreSQL

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v47_50/SchemaUpdater_47_50.java
15 15

  
16 16
import org.apache.log4j.Logger;
17 17

  
18
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
18 19
import eu.etaxonomy.cdm.database.update.ClassBaseTypeUpdater;
19 20
import eu.etaxonomy.cdm.database.update.ColumnAdder;
20 21
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
......
317 318

  
318 319
        //move data
319 320
        stepName = "Copy mediaCreated to new columns";
320
        String query = "UPDATE @@Media@@ "
321
                + " SET mediaCreated_start = Left(Replace(Replace(Replace(mediaCreatedOld, '-', ''), ':', ''), ' ', '_'), 13)"
321
        String queryTemplate = "UPDATE @@Media@@ "
322
                + " SET mediaCreated_start = %s "
322 323
                + " WHERE mediaCreatedOld IS NOT NULL ";
323
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
324
        String queryDefault = String.format(queryTemplate, "Left(Replace(Replace(Replace(mediaCreatedOld, '-', ''), ':', ''), ' ', '_'), 13)");
325
        String queryPostgres = String.format(queryTemplate, "to_char(mediaCreatedOld,'YYYYMMDD HH24MI')");
326
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, queryDefault, tableName, -99)
327
                  .put(DatabaseTypeEnum.PostgreSQL, queryPostgres)
328
                  .putAudited(DatabaseTypeEnum.PostgreSQL, queryPostgres);
324 329
        stepList.add(step);
325 330

  
326 331
        //delete old column

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)