Updated sequence initalization insert to be idempotent

BATCH-2159 provides a tweak to the insert statement used for
initializing the sequence tables used in the job repository database so
that they don't error if run multiple times as well as don't insert
multiple rows.
This commit is contained in:
Michael Minella
2014-10-17 10:53:26 -05:00
parent 2ae6388c12
commit b8238908df
2 changed files with 4 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_SEQ (
constraint UNIQUE_KEY_UN unique (UNIQUE_KEY)
) ENGINE=MYISAM;
INSERT INTO BATCH_STEP_EXECUTION_SEQ values(0, '0');
INSERT INTO BATCH_STEP_EXECUTION_SEQ (ID, UNIQUE_KEY) select * from (select 0 as ID, '0' as UNIQUE_KEY) as tmp where not exists(select * from BATCH_STEP_EXECUTION_SEQ);
CREATE TABLE BATCH_JOB_EXECUTION_SEQ (
ID BIGINT NOT NULL,
@@ -90,7 +90,7 @@ CREATE TABLE BATCH_JOB_EXECUTION_SEQ (
constraint UNIQUE_KEY_UN unique (UNIQUE_KEY)
) ENGINE=MYISAM;
INSERT INTO BATCH_JOB_EXECUTION_SEQ values(0, '0');
INSERT INTO BATCH_JOB_EXECUTION_SEQ (ID, UNIQUE_KEY) select * from (select 0 as ID, '0' as UNIQUE_KEY) as tmp where not exists(select * from BATCH_JOB_EXECUTION_SEQ);
CREATE TABLE BATCH_JOB_SEQ (
ID BIGINT NOT NULL,
@@ -98,4 +98,4 @@ CREATE TABLE BATCH_JOB_SEQ (
constraint UNIQUE_KEY_UN unique (UNIQUE_KEY)
) ENGINE=MYISAM;
INSERT INTO BATCH_JOB_SEQ values(0, '0');
INSERT INTO BATCH_JOB_SEQ (ID, UNIQUE_KEY) select * from (select 0 as ID, '0' as UNIQUE_KEY) as tmp where not exists(select * from BATCH_JOB_SEQ);

View File

@@ -1,6 +1,6 @@
#macro (sequence $name $value)CREATE TABLE ${name} (ID BIGINT NOT NULL,
UNIQUE_KEY CHAR(1) NOT NULL,
constraint ${name}_UN unique (UNIQUE_KEY)) ENGINE=MYISAM;
INSERT INTO ${name} values(0, '0');
INSERT INTO ${name} (ID, UNIQUE_KEY) select * from (select 0 as ID, '0' as UNIQUE_KEY) as tmp where not exists(select * from ${name});
#end
#macro (notnull $name $type)MODIFY COLUMN ${name} ${type} NOT NULL#end