/
symmetric-upgrade.xml
388 lines (372 loc) · 18.9 KB
/
symmetric-upgrade.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-lazy-init="true">
<bean id="upgradeTaskMap" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="0.0" value-ref="upgrade1.0" />
<entry key="1.0" value-ref="upgrade1.0" />
<entry key="1.1" value-ref="upgrade1.1" />
<entry key="1.2" value-ref="upgrade1.2" />
<entry key="1.3" value-ref="upgrade1.3" />
</map>
</constructor-arg>
</bean>
<!-- Upgrade version 1.0 to current version -->
<bean id="upgrade1.0" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="changes-1.1" />
<ref bean="changes-1.2" />
<ref bean="changes-1.2-nonRegServer" />
<ref bean="changes-add-1.3" />
<ref bean="changes-migrate-1.3" />
<ref bean="changes-drop-mysql-1.3" />
<ref bean="changes-drop-1.3" />
</list>
</constructor-arg>
</bean>
<!-- Upgrade version 1.1 to current version -->
<bean id="upgrade1.1" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="changes-1.2" />
<ref bean="changes-1.2-nonRegServer" />
<ref bean="changes-add-1.3" />
<ref bean="changes-migrate-1.3" />
<ref bean="changes-drop-mysql-1.3" />
<ref bean="changes-drop-1.3" />
</list>
</constructor-arg>
</bean>
<!-- Upgrade version 1.2 to current version -->
<bean id="upgrade1.2" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="changes-add-1.3" />
<ref bean="changes-migrate-1.3" />
<ref bean="changes-drop-mysql-1.3" />
<ref bean="changes-drop-1.3" />
</list>
</constructor-arg>
</bean>
<!-- Upgrade version 1.3 to current version -->
<bean id="upgrade1.3" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="changes-1.4-might-fail" />
<ref bean="changes-1.4" />
<ref bean="changes-1.4-might-fail-after" />
</list>
</constructor-arg>
</bean>
<!-- Changes made in version 1.1 -->
<bean id="changes-1.1" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_trigger
add sync_on_incoming_batch numeric(3) default 0
</value>
<value>
alter table ${sync.table.prefix}_data_event
add batched numeric(3) default 0
</value>
<value>
update ${sync.table.prefix}_data_event set batched = '1'
where batch_id is not null
</value>
<value>
create index idx_de_batched_nodeid on
${sync.table.prefix}_data_event(batched, node_id)
</value>
</list>
</property>
</bean>
<!-- Changes made in version 1.2 -->
<bean id="changes-1.2" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="useReplacement" value="false" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_node_security
add initial_load_enabled numeric(1) default 0
</value>
<value>
alter table ${sync.table.prefix}_node_security
add initial_load_time timestamp null
</value>
<value>
update ${sync.table.prefix}_node_security
set initial_load_time = registration_time
</value>
<value>
update sym_trigger
set initial_load_select = 'node_group_id = ''$(groupId)'' or node_group_id in (select source_node_group_id from ${sync.table.prefix}_node_group_link where target_node_group_id = ''$(groupId)'') or node_group_id in (select target_node_group_id from ${sync.table.prefix}_node_group_link where source_node_group_id = ''$(groupId)'')'
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_node_group'
</value>
<value>
update sym_trigger
set initial_load_select = 'source_node_group_id = ''$(groupId)'' or target_node_group_id = ''$(groupId)'''
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_node_group_link'
</value>
<value>
update sym_trigger
set initial_load_select = 'node_id = ''$(nodeId)'' or node_group_id in (select source_node_group_id from ${sync.table.prefix}_node_group_link where target_node_group_id = ''$(groupId)'') or node_group_id in (select target_node_group_id from ${sync.table.prefix}_node_group_link where source_node_group_id = ''$(groupId)'')'
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_node'
</value>
<value>
update sym_trigger
set initial_load_select = 'node_id = ''$(nodeId)'' or node_id in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.source_node_group_id where l.target_node_group_id = ''$(groupId)'') or node_id in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.target_node_group_id where l.source_node_group_id = ''$(groupId)'')'
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_node_security'
</value>
<value>
update sym_trigger
set initial_load_select = 'node_group_id = ''$(groupId)'''
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_global_parameter'
</value>
<value>
update sym_trigger
set initial_load_select = 'channel_id in (select channel_id from ${sync.table.prefix}_trigger where source_node_group_id = ''$(groupId)'')'
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_channel'
</value>
<value>
update sym_trigger
set initial_load_select = 'node_id = ''$(nodeId)'''
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_node_channel_ctl'
</value>
<value>
update sym_trigger
set initial_load_select = 'source_node_group_id = ''$(groupId)'''
where channel_id = 'config' and source_table_name = '${sync.table.prefix}_trigger'
</value>
</list>
</property>
</bean>
<bean id="changes-1.2-nonRegServer" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="upgradeRegistrationServer" value="false" />
<property name="sqlList">
<list>
<value>
delete from ${sync.table.prefix}_node_channel_ctl where
node_id != '$(nodeId)' and
node_id not in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.source_node_group_id where l.target_node_group_id = '$(groupId)') and
node_id not in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.target_node_group_id where l.source_node_group_id = '$(groupId)')
</value>
<value>
delete from ${sync.table.prefix}_node_security where
node_id != '$(nodeId)' and
node_id not in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.source_node_group_id where l.target_node_group_id = '$(groupId)') and
node_id not in (select s.node_id from ${sync.table.prefix}_node s inner join ${sync.table.prefix}_node_group_link l on s.node_group_id = l.target_node_group_id where l.source_node_group_id = '$(groupId)')
</value>
<value>
delete from ${sync.table.prefix}_node where
node_id != '$(nodeId)' and
node_group_id not in (select source_node_group_id from ${sync.table.prefix}_node_group_link where target_node_group_id = '$(groupId)') and
node_group_id not in (select target_node_group_id from ${sync.table.prefix}_node_group_link where source_node_group_id = '$(groupId)')
</value>
</list>
</property>
</bean>
<bean id="changes-add-1.3" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_data_event add channel_id varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_data_event add transaction_id varchar(1000)
</value>
<value>
alter table ${sync.table.prefix}_channel add max_batch_to_send numeric(5) default 60
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add byte_count numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add network_millis numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add filter_millis numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add database_millis numeric(22)
</value>
</list>
</property>
</bean>
<bean id="changes-migrate-1.3" class="org.jumpmind.symmetric.upgrade.SqlDrivenUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="driverSql">
<value>
select channel_id, transaction_id, data_id from ${sync.table.prefix}_data
</value>
</property>
<property name="updateSql">
<value>
update ${sync.table.prefix}_data_event set channel_id=?, transaction_id=? where data_id=?
</value>
</property>
</bean>
<bean id="changes-drop-mysql-1.3" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="dbDialect" ref="dbDialect" />
<property name="dialectName" value="MySQL" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_data drop foreign key fk_d_channel_id
</value>
</list>
</property>
</bean>
<bean id="changes-drop-1.3" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_data drop column channel_id
</value>
<value>
alter table ${sync.table.prefix}_data drop column transaction_id
</value>
<value>
update sym_trigger set last_updated_time=current_timestamp
</value>
</list>
</property>
</bean>
<!-- Changes made in version 1.4 -->
<bean id="changes-1.4" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="sqlList">
<list>
<value>
alter table ${sync.table.prefix}_node_security
add node_password varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_node
add timezone_offset varchar(6)
</value>
<value>
update ${sync.table.prefix}_node_security set node_password = password
</value>
<value>
alter table ${sync.table.prefix}_node_security drop column password
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist drop column history_id
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist drop column event_time
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add node_id varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add start_time timestamp
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add end_time timestamp
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add network_millis numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add filter_millis numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add database_millis numeric(22)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add host_name varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add byte_count numeric(15)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add sql_state varchar(10)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add sql_code numeric(10)
</value>
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist add sql_message varchar(50)
</value>
<value>
create index idx_outgoing_batch_hist on ${sync.table.prefix}_outgoing_batch_hist(node_id, batch_id)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add sql_state varchar(10)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add sql_code numeric(10)
</value>
<value>
alter table ${sync.table.prefix}_incoming_batch_hist add sql_message varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_trigger add source_catalog_name varchar(50)
</value>
<value>
alter table ${sync.table.prefix}_trigger_hist add source_catalog_name varchar(50)
</value>
<value>
drop index idx_de_batched_nodeid
</value>
<value>
create index idx_de_batched_nodeid_channel on
${sync.table.prefix}_data_event(batched, node_id, channel_id)
</value>
</list>
</property>
</bean>
<!-- Changes made in version 1.4 that vary on different database platforms -->
<bean id="changes-1.4-might-fail" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="ignoreFailure" value="true" />
<property name="sqlList">
<list>
<!-- Not PostgreSQL -->
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist drop primary key
</value>
<!-- Oracle -->
<value>
drop trigger TRG_${sync.table.prefix}_OUTGOIN_IST_history_id
</value>
<!-- Oracle -->
<value>
drop sequence seq_${sync.table.prefix}_OUTGOIN_IST_history_id
</value>
<!-- PostgreSQL -->
<value>
alter table ${sync.table.prefix}_outgoing_batch_hist drop constraint ${sync.table.prefix}_outgoing_batch_hist_pkey
</value>
<value>
drop table ${sync.table.prefix}_global_parameter
</value>
</list>
</property>
</bean>
<!-- Changes made in version 1.4 that vary on different database platforms -->
<bean id="changes-1.4-might-fail-after" class="org.jumpmind.symmetric.upgrade.SqlUpgradeTask">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="ignoreFailure" value="true" />
<property name="sqlList">
<list>
<!-- PostgreSQL -->
<value>
drop sequence ${sync.table.prefix}_OUTGOING_BA_history_id_seq
</value>
</list>
</property>
</bean>
</beans>