1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.database.update.v50_51;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.update.ColumnAdder;
|
18
|
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
|
19
|
import eu.etaxonomy.cdm.database.update.ColumnRemover;
|
20
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
|
21
|
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
|
22
|
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
|
23
|
import eu.etaxonomy.cdm.database.update.SimpleSchemaUpdaterStep;
|
24
|
import eu.etaxonomy.cdm.database.update.v47_50.SchemaUpdater_47_50;
|
25
|
|
26
|
/**
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @date 09.06.2017
|
30
|
*
|
31
|
*/
|
32
|
public class SchemaUpdater_50_55 extends SchemaUpdaterBase {
|
33
|
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(SchemaUpdater_50_55.class);
|
36
|
private static final String startSchemaVersion = "5.0.0.0.20180514";
|
37
|
private static final String endSchemaVersion = "5.5.0.0.20190122";
|
38
|
|
39
|
// ********************** FACTORY METHOD *************************************
|
40
|
|
41
|
public static SchemaUpdater_50_55 NewInstance() {
|
42
|
return new SchemaUpdater_50_55();
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* @param startSchemaVersion
|
47
|
* @param endSchemaVersion
|
48
|
*/
|
49
|
protected SchemaUpdater_50_55() {
|
50
|
super(startSchemaVersion, endSchemaVersion);
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
protected List<ISchemaUpdaterStep> getUpdaterList() {
|
55
|
|
56
|
String stepName;
|
57
|
String tableName;
|
58
|
ISchemaUpdaterStep step;
|
59
|
String newColumnName;
|
60
|
String query;
|
61
|
|
62
|
List<ISchemaUpdaterStep> stepList = new ArrayList<>();
|
63
|
|
64
|
|
65
|
//#6699 delete term version
|
66
|
//just in case not fixed before yet
|
67
|
stepName = "Delete term version";
|
68
|
query = "DELETE FROM @@CdmMetaData@@ WHERE propertyName = 'TERM_VERSION'";
|
69
|
step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
|
70
|
stepList.add(step);
|
71
|
|
72
|
//#7414 remove mediaCreatedOld column
|
73
|
stepName = "remove mediaCreatedOld column";
|
74
|
tableName = "Media";
|
75
|
String oldColumnName = "mediaCreatedOld";
|
76
|
step = ColumnRemover.NewInstance(stepName, tableName, oldColumnName, INCLUDE_AUDIT);
|
77
|
stepList.add(step);
|
78
|
|
79
|
//TODO remove proparte and partial columns
|
80
|
|
81
|
//#8004 add sortindex to description element
|
82
|
stepName = "Add sortindex to description element";
|
83
|
tableName = "DescriptionElementBase";
|
84
|
newColumnName = "sortIndex";
|
85
|
step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, null, !NOT_NULL);
|
86
|
stepList.add(step);
|
87
|
|
88
|
//7682 update Point.precision from 0 to null
|
89
|
stepName = "update Point.precision from 0 to null";
|
90
|
query = "UPDATE @@GatheringEvent@@ SET exactLocation_errorRadius = null WHERE exactLocation_errorRadius = 0 ";
|
91
|
tableName = "GatheringEvent";
|
92
|
step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
|
93
|
stepList.add(step);
|
94
|
|
95
|
//#7859 CdmPreference.value as CLOB
|
96
|
stepName = "Make CdmPreference.value a CLOB";
|
97
|
String columnName = "value";
|
98
|
tableName = "CdmPreference";
|
99
|
// TODO check non MySQL and with existing data (probably does not exist)
|
100
|
step = ColumnNameChanger.NewClobInstance(stepName, tableName,
|
101
|
columnName, columnName, INCLUDE_AUDIT);
|
102
|
stepList.add(step);
|
103
|
|
104
|
return stepList;
|
105
|
|
106
|
}
|
107
|
|
108
|
|
109
|
@Override
|
110
|
public ISchemaUpdater getNextUpdater() {
|
111
|
return null;
|
112
|
}
|
113
|
|
114
|
@Override
|
115
|
public ISchemaUpdater getPreviousUpdater() {
|
116
|
return SchemaUpdater_47_50.NewInstance();
|
117
|
}
|
118
|
|
119
|
}
|