Skip to content

Commit 80d4d21

Browse files
authored
Merge pull request #3632 from FOCONIS/reorg-args-placeholder
Db2: Reorg args placeholder
2 parents 16f5311 + fe66b8c commit 80d4d21

File tree

18 files changed

+116
-115
lines changed

18 files changed

+116
-115
lines changed

ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DB2Ddl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected List<AlterCmd> postProcessCommands(List<AlterCmd> cmds) {
202202
}
203203
}
204204
if (requiresReorg) {
205-
ret.add(newRawCommand("call sysproc.admin_cmd('reorg table " + tableName() + "')"));
205+
ret.add(newRawCommand("call sysproc.admin_cmd('reorg table " + tableName() + " ${reorgArgs}')"));
206206
}
207207
return ret;
208208
}

ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void testAlterColumnBaseAttributes() {
136136
+ "alter table mytab alter column acol set data type varchar(50);\n"
137137
+ "alter table mytab alter column acol set default 'hi';\n"
138138
+ "alter table mytab alter column acol set not null;\n"
139-
+ "call sysproc.admin_cmd('reorg table mytab');\n");
139+
+ "call sysproc.admin_cmd('reorg table mytab ${reorgArgs}');\n");
140140

141141
//
142142
alter.setCurrentNotnull(Boolean.TRUE);
@@ -176,7 +176,7 @@ public void testAlterColumnBaseAttributes() {
176176
softly.assertThat(sql).isEqualTo("-- apply alter tables\n"
177177
+ "alter table mytab alter column acol drop default;\n"
178178
+ "alter table mytab alter column acol drop not null;\n"
179-
+ "call sysproc.admin_cmd('reorg table mytab');\n");
179+
+ "call sysproc.admin_cmd('reorg table mytab ${reorgArgs}');\n");
180180

181181
}
182182

@@ -218,7 +218,7 @@ public void testAlterColumnType() {
218218
+ "alter table mytab alter column acol set data type varchar(20);\n"
219219
// Note, this reorg may be not necessary when only length attribute is alterd
220220
// but this is currently not implemented.
221-
+ "call sysproc.admin_cmd('reorg table mytab');\n");
221+
+ "call sysproc.admin_cmd('reorg table mytab ${reorgArgs}');\n");
222222

223223
alter.setType("bigint");
224224
sql = alterColumn(pgDdl, alter);
@@ -277,7 +277,7 @@ public void testAlterColumnNotnull() {
277277
sql = alterColumn(db2Ddl, alter);
278278
softly.assertThat(sql).isEqualTo("-- apply alter tables\n"
279279
+ "alter table mytab alter column acol set not null;\n"
280-
+ "call sysproc.admin_cmd('reorg table mytab');\n");
280+
+ "call sysproc.admin_cmd('reorg table mytab ${reorgArgs}');\n");
281281

282282
}
283283

@@ -321,7 +321,7 @@ public void testAlterColumnNull() {
321321
sql = alterColumn(db2Ddl, alter);
322322
softly.assertThat(sql).isEqualTo("-- apply alter tables\n"
323323
+ "alter table mytab alter column acol drop not null;\n"
324-
+ "call sysproc.admin_cmd('reorg table mytab');\n");
324+
+ "call sysproc.admin_cmd('reorg table mytab ${reorgArgs}');\n");
325325
}
326326

327327
@Test

ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.ArrayList;
2222
import java.util.Collections;
2323
import java.util.List;
24+
import java.util.Map;
2425

2526
import static org.assertj.core.api.Assertions.assertThat;
2627

@@ -40,7 +41,7 @@ public class DbMigrationTest extends BaseTestCase {
4041
private void runScript(String scriptName) {
4142
URL url = getClass().getResource("/migrationtest/dbmigration/" + server().platform().name().toLowerCase() + "/" + scriptName);
4243
assert url != null : scriptName + " not found for platform [" + server().platform().name().toLowerCase() + "]";
43-
server().script().run(url);
44+
server().script().run(url, Map.of("reorgArgs", "use tempspace1 resetdictionary"));
4445
}
4546

4647
@IgnorePlatform({

ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTE
257257
alter table "table" alter column textfield drop not null;
258258
alter table "table" add column "select" varchar(255);
259259
alter table "table" add column textfield2 varchar(255);
260-
call sysproc.admin_cmd('reorg table "table"');
260+
call sysproc.admin_cmd('reorg table "table" ${reorgArgs}');
261261
alter table migtest_ckey_detail add column one_key integer;
262262
alter table migtest_ckey_detail add column two_key varchar(127);
263263
alter table migtest_ckey_parent add column assoc_id integer;
@@ -274,43 +274,43 @@ alter table migtest_e_basic add column new_boolean_field smallint default 0 defa
274274
alter table migtest_e_basic add column new_boolean_field2 smallint default 0 default true not null;
275275
alter table migtest_e_basic add column progress integer default 0 not null;
276276
alter table migtest_e_basic add column new_integer integer default 42 not null;
277-
call sysproc.admin_cmd('reorg table migtest_e_basic');
277+
call sysproc.admin_cmd('reorg table migtest_e_basic ${reorgArgs}');
278278
alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin;
279279
alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end;
280280
alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id;
281281
alter table migtest_e_history add period system_time (sys_period_start,sys_period_end);
282282
alter table migtest_e_history alter column test_string set data type bigint;
283-
call sysproc.admin_cmd('reorg table migtest_e_history');
283+
call sysproc.admin_cmd('reorg table migtest_e_history ${reorgArgs}');
284284
alter table migtest_e_history2 alter column test_string set default 'unknown';
285285
alter table migtest_e_history2 alter column test_string set not null;
286286
alter table migtest_e_history2 add column test_string2 varchar(255);
287287
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
288288
alter table migtest_e_history2 add column new_column varchar(20);
289-
call sysproc.admin_cmd('reorg table migtest_e_history2');
289+
call sysproc.admin_cmd('reorg table migtest_e_history2 ${reorgArgs}');
290290
alter table migtest_e_history2_history alter column test_string set not null;
291291
alter table migtest_e_history2_history add column test_string2 varchar(255);
292292
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null;
293293
alter table migtest_e_history2_history add column new_column varchar(20);
294-
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
294+
call sysproc.admin_cmd('reorg table migtest_e_history2_history ${reorgArgs}');
295295
alter table migtest_e_history4 alter column test_number set data type bigint;
296-
call sysproc.admin_cmd('reorg table migtest_e_history4');
296+
call sysproc.admin_cmd('reorg table migtest_e_history4 ${reorgArgs}');
297297
alter table migtest_e_history4_history alter column test_number set data type bigint;
298-
call sysproc.admin_cmd('reorg table migtest_e_history4_history');
298+
call sysproc.admin_cmd('reorg table migtest_e_history4_history ${reorgArgs}');
299299
alter table migtest_e_history5 add column test_boolean smallint default 0 default false not null;
300300
alter table migtest_e_history5_history add column test_boolean smallint default 0 default false not null;
301301
alter table migtest_e_history6 alter column test_number1 set default 42;
302302
alter table migtest_e_history6 alter column test_number1 set not null;
303303
alter table migtest_e_history6 alter column test_number2 drop not null;
304-
call sysproc.admin_cmd('reorg table migtest_e_history6');
304+
call sysproc.admin_cmd('reorg table migtest_e_history6 ${reorgArgs}');
305305
alter table migtest_e_history6_history alter column test_number1 set not null;
306306
alter table migtest_e_history6_history alter column test_number2 drop not null;
307-
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
307+
call sysproc.admin_cmd('reorg table migtest_e_history6_history ${reorgArgs}');
308308
alter table migtest_e_softdelete add column deleted smallint default 0 default false not null;
309309
alter table migtest_oto_child add column master_id bigint;
310310
alter table table_history alter column textfield drop not null;
311311
alter table table_history add column "select" varchar(255);
312312
alter table table_history add column textfield2 varchar(255);
313-
call sysproc.admin_cmd('reorg table table_history');
313+
call sysproc.admin_cmd('reorg table table_history ${reorgArgs}');
314314
-- apply post alter
315315
create unique index uq_drop_ref_one_to_one_parent_id on drop_ref_one_to_one(parent_id) exclude null keys;
316316
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));

ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.2__dropsFor_1.1.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ alter table migtest_e_basic drop column description_file;
66
alter table migtest_e_basic drop column old_boolean;
77
alter table migtest_e_basic drop column old_boolean2;
88
alter table migtest_e_basic drop column eref_id;
9-
call sysproc.admin_cmd('reorg table migtest_e_basic');
9+
call sysproc.admin_cmd('reorg table migtest_e_basic ${reorgArgs}');
1010
alter table migtest_e_history2 drop column obsolete_string1;
1111
alter table migtest_e_history2 drop column obsolete_string2;
12-
call sysproc.admin_cmd('reorg table migtest_e_history2');
12+
call sysproc.admin_cmd('reorg table migtest_e_history2 ${reorgArgs}');
1313
alter table migtest_e_history2_history drop column obsolete_string1;
1414
alter table migtest_e_history2_history drop column obsolete_string2;
15-
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
15+
call sysproc.admin_cmd('reorg table migtest_e_history2_history ${reorgArgs}');
1616
-- apply post alter
1717
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
1818
drop table "migtest_QuOtEd";

ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,28 +266,28 @@ alter table migtest_e_basic add column description_file blob(64M);
266266
alter table migtest_e_basic add column old_boolean smallint default 0 default false not null;
267267
alter table migtest_e_basic add column old_boolean2 smallint default 0;
268268
alter table migtest_e_basic add column eref_id integer;
269-
call sysproc.admin_cmd('reorg table migtest_e_basic');
269+
call sysproc.admin_cmd('reorg table migtest_e_basic ${reorgArgs}');
270270
alter table migtest_e_history2 alter column test_string drop default;
271271
alter table migtest_e_history2 alter column test_string drop not null;
272272
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
273273
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
274-
call sysproc.admin_cmd('reorg table migtest_e_history2');
274+
call sysproc.admin_cmd('reorg table migtest_e_history2 ${reorgArgs}');
275275
alter table migtest_e_history2_history alter column test_string drop not null;
276276
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
277277
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
278-
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
278+
call sysproc.admin_cmd('reorg table migtest_e_history2_history ${reorgArgs}');
279279
alter table migtest_e_history4 alter column test_number set data type integer;
280-
call sysproc.admin_cmd('reorg table migtest_e_history4');
280+
call sysproc.admin_cmd('reorg table migtest_e_history4 ${reorgArgs}');
281281
alter table migtest_e_history4_history alter column test_number set data type integer;
282-
call sysproc.admin_cmd('reorg table migtest_e_history4_history');
282+
call sysproc.admin_cmd('reorg table migtest_e_history4_history ${reorgArgs}');
283283
alter table migtest_e_history6 alter column test_number1 drop default;
284284
alter table migtest_e_history6 alter column test_number1 drop not null;
285285
alter table migtest_e_history6 alter column test_number2 set default 7;
286286
alter table migtest_e_history6 alter column test_number2 set not null;
287-
call sysproc.admin_cmd('reorg table migtest_e_history6');
287+
call sysproc.admin_cmd('reorg table migtest_e_history6 ${reorgArgs}');
288288
alter table migtest_e_history6_history alter column test_number1 drop not null;
289289
alter table migtest_e_history6_history alter column test_number2 set not null;
290-
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
290+
call sysproc.admin_cmd('reorg table migtest_e_history6_history ${reorgArgs}');
291291
-- apply post alter
292292
create unique index uq_migtest_quoted_status2 on "migtest_QuOtEd"(status2) exclude null keys;
293293
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);

ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@ alter table "table" drop versioning;
88
-- apply alter tables
99
alter table "table" drop column textfield;
1010
alter table "table" drop column textfield2;
11-
call sysproc.admin_cmd('reorg table "table"');
11+
call sysproc.admin_cmd('reorg table "table" ${reorgArgs}');
1212
alter table migtest_ckey_detail drop column one_key;
1313
alter table migtest_ckey_detail drop column two_key;
14-
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
14+
call sysproc.admin_cmd('reorg table migtest_ckey_detail ${reorgArgs}');
1515
alter table migtest_ckey_parent drop column assoc_id;
16-
call sysproc.admin_cmd('reorg table migtest_ckey_parent');
16+
call sysproc.admin_cmd('reorg table migtest_ckey_parent ${reorgArgs}');
1717
alter table migtest_e_basic drop column new_string_field;
1818
alter table migtest_e_basic drop column new_boolean_field;
1919
alter table migtest_e_basic drop column new_boolean_field2;
2020
alter table migtest_e_basic drop column progress;
2121
alter table migtest_e_basic drop column new_integer;
22-
call sysproc.admin_cmd('reorg table migtest_e_basic');
22+
call sysproc.admin_cmd('reorg table migtest_e_basic ${reorgArgs}');
2323
alter table migtest_e_history drop column sys_period_start;
2424
alter table migtest_e_history drop column sys_period_end;
2525
alter table migtest_e_history drop column sys_period_txn;
26-
call sysproc.admin_cmd('reorg table migtest_e_history');
26+
call sysproc.admin_cmd('reorg table migtest_e_history ${reorgArgs}');
2727
alter table migtest_e_history2 drop column test_string2;
2828
alter table migtest_e_history2 drop column test_string3;
2929
alter table migtest_e_history2 drop column new_column;
30-
call sysproc.admin_cmd('reorg table migtest_e_history2');
30+
call sysproc.admin_cmd('reorg table migtest_e_history2 ${reorgArgs}');
3131
alter table migtest_e_history2_history drop column test_string2;
3232
alter table migtest_e_history2_history drop column test_string3;
3333
alter table migtest_e_history2_history drop column new_column;
34-
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
34+
call sysproc.admin_cmd('reorg table migtest_e_history2_history ${reorgArgs}');
3535
alter table migtest_e_history5 drop column test_boolean;
36-
call sysproc.admin_cmd('reorg table migtest_e_history5');
36+
call sysproc.admin_cmd('reorg table migtest_e_history5 ${reorgArgs}');
3737
alter table migtest_e_history5_history drop column test_boolean;
38-
call sysproc.admin_cmd('reorg table migtest_e_history5_history');
38+
call sysproc.admin_cmd('reorg table migtest_e_history5_history ${reorgArgs}');
3939
alter table migtest_e_softdelete drop column deleted;
40-
call sysproc.admin_cmd('reorg table migtest_e_softdelete');
40+
call sysproc.admin_cmd('reorg table migtest_e_softdelete ${reorgArgs}');
4141
alter table migtest_oto_child drop column master_id;
42-
call sysproc.admin_cmd('reorg table migtest_oto_child');
42+
call sysproc.admin_cmd('reorg table migtest_oto_child ${reorgArgs}');
4343
alter table table_history drop column textfield;
4444
alter table table_history drop column textfield2;
45-
call sysproc.admin_cmd('reorg table table_history');
45+
call sysproc.admin_cmd('reorg table table_history ${reorgArgs}');
4646
-- apply post alter
4747
drop table migtest_e_history_history;
4848
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-1467839063, 1.0__initial.sql
2-
638526085, 1.1.sql
3-
-1187336846, 1.2__dropsFor_1.1.sql
4-
1085159289, 1.3.sql
5-
2087595324, 1.4__dropsFor_1.3.sql
2+
1478696712, 1.1.sql
3+
471523099, 1.2__dropsFor_1.1.sql
4+
-1492660695, 1.3.sql
5+
1942648765, 1.4__dropsFor_1.3.sql
66
561281075, R__order_views.sql
77

ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTE
257257
alter table "table" alter column textfield drop not null;
258258
alter table "table" add column "select" varchar(255);
259259
alter table "table" add column textfield2 varchar(255);
260-
call sysproc.admin_cmd('reorg table "table"');
260+
call sysproc.admin_cmd('reorg table "table" ${reorgArgs}');
261261
alter table migtest_ckey_detail add column one_key integer;
262262
alter table migtest_ckey_detail add column two_key varchar(127);
263263
alter table migtest_ckey_parent add column assoc_id integer;
@@ -274,43 +274,43 @@ alter table migtest_e_basic add column new_boolean_field boolean default true no
274274
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
275275
alter table migtest_e_basic add column progress integer default 0 not null;
276276
alter table migtest_e_basic add column new_integer integer default 42 not null;
277-
call sysproc.admin_cmd('reorg table migtest_e_basic');
277+
call sysproc.admin_cmd('reorg table migtest_e_basic ${reorgArgs}');
278278
alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin;
279279
alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end;
280280
alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id;
281281
alter table migtest_e_history add period system_time (sys_period_start,sys_period_end);
282282
alter table migtest_e_history alter column test_string set data type bigint;
283-
call sysproc.admin_cmd('reorg table migtest_e_history');
283+
call sysproc.admin_cmd('reorg table migtest_e_history ${reorgArgs}');
284284
alter table migtest_e_history2 alter column test_string set default 'unknown';
285285
alter table migtest_e_history2 alter column test_string set not null;
286286
alter table migtest_e_history2 add column test_string2 varchar(255);
287287
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
288288
alter table migtest_e_history2 add column new_column varchar(20);
289-
call sysproc.admin_cmd('reorg table migtest_e_history2');
289+
call sysproc.admin_cmd('reorg table migtest_e_history2 ${reorgArgs}');
290290
alter table migtest_e_history2_history alter column test_string set not null;
291291
alter table migtest_e_history2_history add column test_string2 varchar(255);
292292
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null;
293293
alter table migtest_e_history2_history add column new_column varchar(20);
294-
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
294+
call sysproc.admin_cmd('reorg table migtest_e_history2_history ${reorgArgs}');
295295
alter table migtest_e_history4 alter column test_number set data type bigint;
296-
call sysproc.admin_cmd('reorg table migtest_e_history4');
296+
call sysproc.admin_cmd('reorg table migtest_e_history4 ${reorgArgs}');
297297
alter table migtest_e_history4_history alter column test_number set data type bigint;
298-
call sysproc.admin_cmd('reorg table migtest_e_history4_history');
298+
call sysproc.admin_cmd('reorg table migtest_e_history4_history ${reorgArgs}');
299299
alter table migtest_e_history5 add column test_boolean boolean default false not null;
300300
alter table migtest_e_history5_history add column test_boolean boolean default false not null;
301301
alter table migtest_e_history6 alter column test_number1 set default 42;
302302
alter table migtest_e_history6 alter column test_number1 set not null;
303303
alter table migtest_e_history6 alter column test_number2 drop not null;
304-
call sysproc.admin_cmd('reorg table migtest_e_history6');
304+
call sysproc.admin_cmd('reorg table migtest_e_history6 ${reorgArgs}');
305305
alter table migtest_e_history6_history alter column test_number1 set not null;
306306
alter table migtest_e_history6_history alter column test_number2 drop not null;
307-
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
307+
call sysproc.admin_cmd('reorg table migtest_e_history6_history ${reorgArgs}');
308308
alter table migtest_e_softdelete add column deleted boolean default false not null;
309309
alter table migtest_oto_child add column master_id bigint;
310310
alter table table_history alter column textfield drop not null;
311311
alter table table_history add column "select" varchar(255);
312312
alter table table_history add column textfield2 varchar(255);
313-
call sysproc.admin_cmd('reorg table table_history');
313+
call sysproc.admin_cmd('reorg table table_history ${reorgArgs}');
314314
-- apply post alter
315315
create unique index uq_drop_ref_one_to_one_parent_id on drop_ref_one_to_one(parent_id) exclude null keys;
316316
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));

0 commit comments

Comments
 (0)