Skip to content

Commit

Permalink
fix MigratorSpec akka#710
Browse files Browse the repository at this point in the history
  • Loading branch information
Roiocam authored and AndyChen committed Oct 8, 2023
1 parent 1a1de91 commit f32e511
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
10 changes: 6 additions & 4 deletions migrator/src/test/resources/schema/h2/h2-create-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ CREATE TABLE IF NOT EXISTS "event_journal" (
CREATE UNIQUE INDEX "event_journal_ordering_idx" on "event_journal" ("ordering");

CREATE TABLE IF NOT EXISTS "event_tag" (
"event_id" BIGINT NOT NULL,
"event_id" BIGINT,
"persistence_id" VARCHAR(255),
"sequence_number" BIGINT,
"tag" VARCHAR NOT NULL,
PRIMARY KEY("event_id", "tag"),
PRIMARY KEY("persistence_id", "sequence_number", "tag"),
CONSTRAINT fk_event_journal
FOREIGN KEY("event_id")
REFERENCES "event_journal"("ordering")
FOREIGN KEY("persistence_id", "sequence_number")
REFERENCES "event_journal"("persistence_id", "sequence_number")
ON DELETE CASCADE
);

Expand Down
12 changes: 7 additions & 5 deletions migrator/src/test/resources/schema/mysql/mysql-create-schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS event_journal(
CREATE TABLE IF NOT EXISTS event_journal (
ordering SERIAL,
deleted BOOLEAN DEFAULT false NOT NULL,
persistence_id VARCHAR(255) NOT NULL,
Expand All @@ -17,11 +17,13 @@ CREATE TABLE IF NOT EXISTS event_journal(
CREATE UNIQUE INDEX event_journal_ordering_idx ON event_journal(ordering);

CREATE TABLE IF NOT EXISTS event_tag (
event_id BIGINT UNSIGNED NOT NULL,
event_id BIGINT UNSIGNED,
persistence_id VARCHAR(255),
sequence_number BIGINT,
tag VARCHAR(255) NOT NULL,
PRIMARY KEY(event_id, tag),
FOREIGN KEY (event_id)
REFERENCES event_journal(ordering)
PRIMARY KEY(persistence_id, sequence_number, tag),
FOREIGN KEY (persistence_id, sequence_number)
REFERENCES event_journal(persistence_id, sequence_number)
ON DELETE CASCADE
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ CREATE OR REPLACE TRIGGER EVENT_JOURNAL__ORDERING_TRG before insert on EVENT_JOU
/

CREATE TABLE EVENT_TAG (
EVENT_ID NUMERIC NOT NULL,
EVENT_ID NUMERIC,
PERSISTENCE_ID VARCHAR(255),
SEQUENCE_NUMBER NUMERIC,
TAG VARCHAR(255) NOT NULL,
PRIMARY KEY(EVENT_ID, TAG),
FOREIGN KEY(EVENT_ID) REFERENCES EVENT_JOURNAL(ORDERING)
PRIMARY KEY(PERSISTENCE_ID, SEQUENCE_NUMBER, TAG),
FOREIGN KEY(PERSISTENCE_ID, SEQUENCE_NUMBER) REFERENCES EVENT_JOURNAL(PERSISTENCE_ID, SEQUENCE_NUMBER)
ON DELETE CASCADE
)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ CREATE UNIQUE INDEX event_journal_ordering_idx ON public.event_journal(ordering)

CREATE TABLE IF NOT EXISTS public.event_tag(
event_id BIGINT,
persistence_id VARCHAR(255),
sequence_number BIGINT,
tag VARCHAR(256),
PRIMARY KEY(event_id, tag),
PRIMARY KEY(persistence_id, sequence_number, tag),
CONSTRAINT fk_event_journal
FOREIGN KEY(event_id)
REFERENCES event_journal(ordering)
FOREIGN KEY(persistence_id, sequence_number)
REFERENCES event_journal(persistence_id, sequence_number)
ON DELETE CASCADE
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ CREATE TABLE event_journal(
CREATE UNIQUE INDEX event_journal_ordering_idx ON event_journal(ordering);

CREATE TABLE event_tag (
"event_id" BIGINT NOT NULL,
"tag" VARCHAR(255) NOT NULL
PRIMARY KEY ("event_id","tag")
"event_id" BIGINT,
"persistence_id" VARCHAR(255),
"sequence_number" NUMERIC(10,0),
"tag" VARCHAR(255) NOT NULL,
PRIMARY KEY ("event_id", "tag"),
constraint "fk_event_journal"
foreign key("event_id")
references "dbo"."event_journal"("ordering")
Expand Down

0 comments on commit f32e511

Please sign in to comment.