This is an automated email from the ASF dual-hosted git repository.
roiocam pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git
The following commit(s) were added to refs/heads/main by this push:
new ed3dafc fix: migrator-integration-test tests not running #191 (#192)
ed3dafc is described below
commit ed3dafc609698e8e743d21d05f16dcfccce4c275
Author: AndyChen(Jingzhang) <[email protected]>
AuthorDate: Tue May 21 10:19:50 2024 +0800
fix: migrator-integration-test tests not running #191 (#192)
* rename migrator integration test package
* fix migrator dependency
* extra ci job for migrator it
* move configuration to it module
* Increase waiting time.
* fix issue migrator, clean code
* remove header and remove code change
* skip SQLServer
* skip Run Migrator in old DAO
* fix oracle schema override
* remove deprecated soft delete SQL
* fix ci condition
* fix oracle clean up
* fix sqlserver insert
---
.github/workflows/mysql-tests.yml | 4 +
.github/workflows/oracle-tests.yml | 4 +
.github/workflows/postgres-tests.yml | 4 +
.github/workflows/sqlserver-tests.yml | 4 +
build.sbt | 4 +-
.../schema/oracle/oracle-drop-schema-legacy.sql | 3 -
.../src/test/resources/general.conf | 0
.../src/test/resources/h2-application.conf | 0
.../src/test/resources/mysql-application.conf | 0
.../src/test/resources/oracle-application.conf | 0
.../test/resources/oracle-schema-overrides.conf | 125 +++++++++++++++++++++
.../src/test/resources/postgres-application.conf | 0
.../schema/h2/h2-create-schema-legacy.sql | 0
.../resources/schema/h2/h2-drop-schema-legacy.sql | 0
.../schema/mysql/mysql-create-schema-legacy.sql | 0
.../schema/mysql/mysql-drop-schema-legacy.sql | 0
.../schema/oracle/oracle-create-schema-legacy.sql | 41 +++++++
.../schema/oracle/oracle-drop-schema-legacy.sql | 18 +++
.../postgres/postgres-create-schema-legacy.sql | 0
.../postgres/postgres-drop-schema-legacy.sql | 0
.../sqlserver/sqlserver-create-schema-legacy.sql | 8 +-
.../sqlserver/sqlserver-drop-schema-legacy.sql | 0
.../src/test/resources/sqlserver-application.conf | 0
.../jdbc/migrator/JournalMigratorTest.scala | 0
.../persistence/jdbc/migrator/MigratorSpec.scala | 1 +
.../jdbc/migrator/SnapshotMigratorTest.scala | 0
.../jdbc/migrator/JournalMigrator.scala | 14 +--
.../test/resources/schema/h2/h2-create-schema.sql | 56 ---------
.../test/resources/schema/h2/h2-drop-schema.sql | 5 -
.../resources/schema/mysql/mysql-create-schema.sql | 38 -------
.../resources/schema/mysql/mysql-drop-schema.sql | 3 -
.../schema/oracle/oracle-create-schema-legacy.sql | 44 --------
.../schema/oracle/oracle-create-schema.sql | 57 ----------
.../schema/oracle/oracle-drop-schema-legacy.sql | 21 ----
.../resources/schema/oracle/oracle-drop-schema.sql | 20 ----
.../schema/postgres/postgres-create-schema.sql | 62 ----------
.../schema/postgres/postgres-drop-schema.sql | 5 -
.../schema/sqlserver/sqlserver-create-schema.sql | 42 -------
.../schema/sqlserver/sqlserver-drop-schema.sql | 3 -
39 files changed, 210 insertions(+), 376 deletions(-)
diff --git a/.github/workflows/mysql-tests.yml
b/.github/workflows/mysql-tests.yml
index 1b0c735..4436c63 100644
--- a/.github/workflows/mysql-tests.yml
+++ b/.github/workflows/mysql-tests.yml
@@ -48,6 +48,10 @@ jobs:
- name: Run Integration tests for ${{ matrix.name }}
run: sbt ++2.13 "integration/testOnly
org.apache.pekko.persistence.jdbc.integration.MySQL*" ${{ matrix.extraOpts }}
-J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+ - name: Run Migrator Integration tests for ${{ matrix.name }}
+ if: matrix.name == 'MySQL'
+ run: sbt ++2.13 "migratorIntegration/testOnly
org.apache.pekko.persistence.jdbc.migrator.integration.MySQL*" ${{
matrix.extraOpts }} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+
- name: Print logs on failure
if: ${{ failure() }}
run: find . -name "*.log" -exec ./scripts/cat-log.sh {} \;
diff --git a/.github/workflows/oracle-tests.yml
b/.github/workflows/oracle-tests.yml
index 894c737..7a78cab 100644
--- a/.github/workflows/oracle-tests.yml
+++ b/.github/workflows/oracle-tests.yml
@@ -48,6 +48,10 @@ jobs:
- name: Run Integration tests for ${{ matrix.name }}
run: sbt ++2.13 "integration/testOnly
org.apache.pekko.persistence.jdbc.integration.Oracle*" ${{ matrix.extraOpts }}
-J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+ - name: Run Migrator Integration tests for ${{ matrix.name }}
+ if: matrix.name == 'Oracle'
+ run: sbt ++2.13 "migratorIntegration/testOnly
org.apache.pekko.persistence.jdbc.migrator.integration.Oracle*" ${{
matrix.extraOpts }} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+
- name: Print logs on failure
if: ${{ failure() }}
run: find . -name "*.log" -exec ./scripts/cat-log.sh {} \;
diff --git a/.github/workflows/postgres-tests.yml
b/.github/workflows/postgres-tests.yml
index 31233bb..c20fe5b 100644
--- a/.github/workflows/postgres-tests.yml
+++ b/.github/workflows/postgres-tests.yml
@@ -48,6 +48,10 @@ jobs:
- name: Run Integration tests for ${{ matrix.name }}
run: sbt ++2.13 "integration/testOnly
org.apache.pekko.persistence.jdbc.integration.Postgres*" ${{ matrix.extraOpts
}} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+ - name: Run Migrator Integration tests for ${{ matrix.name }}
+ if: matrix.name == 'Postgres'
+ run: sbt ++2.13 "migratorIntegration/testOnly
org.apache.pekko.persistence.jdbc.migrator.integration.Postgres*" ${{
matrix.extraOpts }} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+
- name: Print logs on failure
if: ${{ failure() }}
run: find . -name "*.log" -exec ./scripts/cat-log.sh {} \;
diff --git a/.github/workflows/sqlserver-tests.yml
b/.github/workflows/sqlserver-tests.yml
index a8901bd..670fdbd 100644
--- a/.github/workflows/sqlserver-tests.yml
+++ b/.github/workflows/sqlserver-tests.yml
@@ -48,6 +48,10 @@ jobs:
- name: Run Integration tests for ${{ matrix.name }}
run: sbt ++2.13 "integration/testOnly
org.apache.pekko.persistence.jdbc.integration.SqlServer*" ${{ matrix.extraOpts
}} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+ - name: Run Migrator Integration tests for ${{ matrix.name }}
+ if: matrix.name == 'SqlServer'
+ run: sbt ++2.13 "migratorIntegration/testOnly
org.apache.pekko.persistence.jdbc.migrator.integration.SqlServer*" ${{
matrix.extraOpts }} -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseJVMCICompiler
+
- name: Print logs on failure
if: ${{ failure() }}
run: find . -name "*.log" -exec ./scripts/cat-log.sh {} \;
diff --git a/build.sbt b/build.sbt
index 7e418d9..04fe4e5 100644
--- a/build.sbt
+++ b/build.sbt
@@ -25,7 +25,7 @@ lazy val `pekko-persistence-jdbc` = project
.in(file("."))
.enablePlugins(ScalaUnidocPlugin)
.disablePlugins(MimaPlugin, SitePlugin)
- .aggregate(core, migrator, integration, docs)
+ .aggregate(core, migrator, docs)
.settings(
name := "pekko-persistence-jdbc-root",
publish / skip := true)
@@ -63,7 +63,7 @@ lazy val migratorIntegration = project
.settings(name := "pekko-persistence-jdbc-migrator-integration",
libraryDependencies ++= Dependencies.Libraries)
.settings(publish / skip := true, doc / sources := Seq.empty, Test / fork :=
true)
.disablePlugins(MimaPlugin, SitePlugin)
- .dependsOn(core % "compile->compile;test->test")
+ .dependsOn(core % "compile->compile;test->test", migrator %
"compile->compile;test->test")
lazy val themeSettings = Seq(
pekkoParadoxGithub :=
Some("https://github.com/apache/pekko-persistence-jdbc"))
diff --git
a/core/src/main/resources/schema/oracle/oracle-drop-schema-legacy.sql
b/core/src/main/resources/schema/oracle/oracle-drop-schema-legacy.sql
index 572693a..7368a8d 100644
--- a/core/src/main/resources/schema/oracle/oracle-drop-schema-legacy.sql
+++ b/core/src/main/resources/schema/oracle/oracle-drop-schema-legacy.sql
@@ -8,9 +8,6 @@ DROP TABLE "journal" CASCADE CONSTRAINT
DROP TABLE "snapshot" CASCADE CONSTRAINT
/
-DROP TABLE "deleted_to" CASCADE CONSTRAINT
-/
-
DROP TRIGGER "ordering_seq_trigger"
/
diff --git a/migrator/src/test/resources/general.conf
b/migrator-integration-test/src/test/resources/general.conf
similarity index 100%
rename from migrator/src/test/resources/general.conf
rename to migrator-integration-test/src/test/resources/general.conf
diff --git a/migrator/src/test/resources/h2-application.conf
b/migrator-integration-test/src/test/resources/h2-application.conf
similarity index 100%
rename from migrator/src/test/resources/h2-application.conf
rename to migrator-integration-test/src/test/resources/h2-application.conf
diff --git a/migrator/src/test/resources/mysql-application.conf
b/migrator-integration-test/src/test/resources/mysql-application.conf
similarity index 100%
rename from migrator/src/test/resources/mysql-application.conf
rename to migrator-integration-test/src/test/resources/mysql-application.conf
diff --git a/migrator/src/test/resources/oracle-application.conf
b/migrator-integration-test/src/test/resources/oracle-application.conf
similarity index 100%
rename from migrator/src/test/resources/oracle-application.conf
rename to migrator-integration-test/src/test/resources/oracle-application.conf
diff --git
a/migrator-integration-test/src/test/resources/oracle-schema-overrides.conf
b/migrator-integration-test/src/test/resources/oracle-schema-overrides.conf
new file mode 100644
index 0000000..704a37c
--- /dev/null
+++ b/migrator-integration-test/src/test/resources/oracle-schema-overrides.conf
@@ -0,0 +1,125 @@
+# SPDX-License-Identifier: Apache-2.0
+
+# Oracle does not support returning a column with a case senstive name so all
the column names and table names need
+# to be caps. See:
+# https://github.com/slick/slick/issues/47
+# https://groups.google.com/g/scalaquery/c/U431n-Z2cwM
+
+jdbc-snapshot-store {
+ tables {
+
+ legacy_snapshot {
+ tableName = "LEGACY_SNAPSHOT"
+ schemaName = "SYSTEM"
+ columnNames {
+ persistenceId = "PERSISTENCE_ID"
+ sequenceNumber = "SEQUENCE_NUMBER"
+ created = "CREATED"
+ snapshot = "SNAPSHOT"
+ }
+ }
+
+
+ snapshot {
+ tableName = "SNAPSHOT"
+ schemaName = "SYSTEM"
+ columnNames {
+ persistenceId = "PERSISTENCE_ID"
+ sequenceNumber = "SEQUENCE_NUMBER"
+ created = "CREATED"
+
+ snapshotPayload = "SNAPSHOT_PAYLOAD"
+ snapshotSerId = "SNAPSHOT_SER_ID"
+ snapshotSerManifest = "SNAPSHOT_SER_MANIFEST"
+
+ metaPayload = "META_PAYLOAD"
+ metaSerId = "META_SER_ID"
+ metaSerManifest = "META_SER_MANIFEST"
+ }
+ }
+ }
+}
+
+jdbc-read-journal {
+ tables {
+ event_journal {
+ tableName = "EVENT_JOURNAL"
+ schemaName = "SYSTEM"
+ }
+ legacy_journal {
+ tableName = "JOURNAL"
+ schemaName = "SYSTEM"
+ }
+ }
+}
+
+jdbc-journal {
+ tables {
+ legacy_journal {
+ tableName = "JOURNAL"
+ schemaName = "SYSTEM"
+
+ columnNames {
+ ordering = "ORDERING"
+ deleted = "DELETED"
+ persistenceId = "PERSISTENCE_ID"
+ sequenceNumber = "SEQUENCE_NUMBER"
+ created = "CREATED"
+ tags = "TAGS"
+ message = "MESSAGE"
+ }
+ }
+
+ event_journal {
+ tableName = "EVENT_JOURNAL"
+ schemaName = "SYSTEM"
+
+ columnNames {
+ ordering = "ORDERING"
+ deleted = "DELETED"
+ persistenceId = "PERSISTENCE_ID"
+ sequenceNumber = "SEQUENCE_NUMBER"
+ writer = "WRITER",
+ writeTimestamp = "WRITE_TIMESTAMP"
+ adapterManifest = "ADAPTER_MANIFEST"
+ eventPayload = "EVENT_PAYLOAD"
+ eventSerId = "EVENT_SER_ID"
+ eventSerManifest = "EVENT_SER_MANIFEST"
+ metaPayload = "META_PAYLOAD"
+ metaSerId = "META_SER_ID"
+ metaSerManifest = "META_SER_MANIFEST"
+ }
+ }
+
+ event_tag {
+ tableName = "EVENT_TAG"
+ schemaName = "SYSTEM"
+
+ columnNames {
+ eventId = "EVENT_ID"
+ tag = "TAG"
+ }
+ }
+ }
+
+}
+
+jdbc-durable-state-store {
+ tables {
+ durable_state {
+ tableName = "DURABLE_STATE"
+ schemaName = "SYSTEM"
+
+ columnNames {
+ globalOffset = "GLOBAL_OFFSET"
+ persistenceId = "PERSISTENCE_ID"
+ revision = "REVISION"
+ statePayload = "STATE_PAYLOAD"
+ stateSerId = "STATE_SERIAL_ID"
+ stateSerManifest = "STATE_SERIAL_MANIFEST"
+ tag = "TAG"
+ stateTimestamp = "STATE_TIMESTAMP"
+ }
+ }
+ }
+}
diff --git a/migrator/src/test/resources/postgres-application.conf
b/migrator-integration-test/src/test/resources/postgres-application.conf
similarity index 100%
rename from migrator/src/test/resources/postgres-application.conf
rename to migrator-integration-test/src/test/resources/postgres-application.conf
diff --git a/migrator/src/test/resources/schema/h2/h2-create-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/h2/h2-create-schema-legacy.sql
similarity index 100%
rename from migrator/src/test/resources/schema/h2/h2-create-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/h2/h2-create-schema-legacy.sql
diff --git a/migrator/src/test/resources/schema/h2/h2-drop-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/h2/h2-drop-schema-legacy.sql
similarity index 100%
rename from migrator/src/test/resources/schema/h2/h2-drop-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/h2/h2-drop-schema-legacy.sql
diff --git
a/migrator/src/test/resources/schema/mysql/mysql-create-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/mysql/mysql-create-schema-legacy.sql
similarity index 100%
rename from
migrator/src/test/resources/schema/mysql/mysql-create-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/mysql/mysql-create-schema-legacy.sql
diff --git
a/migrator/src/test/resources/schema/mysql/mysql-drop-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/mysql/mysql-drop-schema-legacy.sql
similarity index 100%
rename from
migrator/src/test/resources/schema/mysql/mysql-drop-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/mysql/mysql-drop-schema-legacy.sql
diff --git
a/migrator-integration-test/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
new file mode 100644
index 0000000..81efa5a
--- /dev/null
+++
b/migrator-integration-test/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
@@ -0,0 +1,41 @@
+CREATE SEQUENCE ORDERING__SEQ START WITH 1 INCREMENT BY 1 NOMAXVALUE
+/
+
+CREATE TABLE JOURNAL (
+ ORDERING NUMERIC UNIQUE,
+ DELETED CHAR(1) DEFAULT 0 NOT NULL check (DELETED in (0, 1)),
+ PERSISTENCE_ID VARCHAR(255) NOT NULL,
+ SEQUENCE_NUMBER NUMERIC NOT NULL,
+ TAGS VARCHAR(255) DEFAULT NULL,
+ MESSAGE BLOB NOT NULL,
+ PRIMARY KEY(PERSISTENCE_ID, SEQUENCE_NUMBER)
+)
+/
+
+CREATE TABLE LEGACY_SNAPSHOT (
+ PERSISTENCE_ID VARCHAR(255) NOT NULL,
+ SEQUENCE_NUMBER NUMERIC NOT NULL,
+ CREATED NUMERIC NOT NULL,
+ SNAPSHOT BLOB NOT NULL,
+ PRIMARY KEY(PERSISTENCE_ID,SEQUENCE_NUMBER)
+)
+/
+
+CREATE OR REPLACE TRIGGER JOURNAL__ORDERING_TRG
+BEFORE INSERT ON JOURNAL
+FOR EACH ROW
+BEGIN
+ SELECT ORDERING__SEQ.NEXTVAL INTO :NEW.ORDERING FROM DUAL;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE "reset_legacy_sequence"
+IS
+ l_value NUMBER;
+BEGIN
+ EXECUTE IMMEDIATE 'SELECT ORDERING__SEQ.nextval FROM dual' INTO l_value;
+ EXECUTE IMMEDIATE 'ALTER SEQUENCE ORDERING__SEQ INCREMENT BY -' || l_value
|| ' MINVALUE 0';
+ EXECUTE IMMEDIATE 'SELECT ORDERING__SEQ.nextval FROM dual' INTO l_value;
+ EXECUTE IMMEDIATE 'ALTER SEQUENCE ORDERING__SEQ INCREMENT BY 1 MINVALUE 0';
+END;
+/
diff --git
a/migrator-integration-test/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
new file mode 100644
index 0000000..5b93c83
--- /dev/null
+++
b/migrator-integration-test/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
@@ -0,0 +1,18 @@
+-- (ddl lock timeout in seconds) this allows tests which are still writing to
the db to finish gracefully
+ALTER SESSION SET ddl_lock_timeout = 150
+/
+
+DROP TRIGGER JOURNAL__ORDERING_TRG
+/
+
+DROP PROCEDURE "reset_legacy_sequence"
+/
+
+DROP SEQUENCE ORDERING__SEQ
+/
+
+DROP TABLE JOURNAL CASCADE CONSTRAINT
+/
+
+DROP TABLE LEGACY_SNAPSHOT CASCADE CONSTRAINT
+/
diff --git
a/migrator/src/test/resources/schema/postgres/postgres-create-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/postgres/postgres-create-schema-legacy.sql
similarity index 100%
rename from
migrator/src/test/resources/schema/postgres/postgres-create-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/postgres/postgres-create-schema-legacy.sql
diff --git
a/migrator/src/test/resources/schema/postgres/postgres-drop-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/postgres/postgres-drop-schema-legacy.sql
similarity index 100%
rename from
migrator/src/test/resources/schema/postgres/postgres-drop-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/postgres/postgres-drop-schema-legacy.sql
diff --git
a/migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
similarity index 66%
rename from
migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
index 12ba4d4..f89beab 100644
---
a/migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
+++
b/migrator-integration-test/src/test/resources/schema/sqlserver/sqlserver-create-schema-legacy.sql
@@ -1,5 +1,3 @@
-IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id =
OBJECT_ID(N'"journal"') AND type in (N'U'))
-begin
CREATE TABLE journal (
"ordering" BIGINT IDENTITY(1,1) NOT NULL,
"deleted" BIT DEFAULT 0 NOT NULL,
@@ -9,11 +7,8 @@ CREATE TABLE journal (
"message" VARBINARY(max) NOT NULL,
PRIMARY KEY ("persistence_id", "sequence_number")
)
-CREATE UNIQUE INDEX journal_ordering_idx ON journal (ordering)
-end;
+CREATE UNIQUE INDEX journal_ordering_idx ON journal (ordering);
-
-IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id =
OBJECT_ID(N'"snapshot"') AND type in (N'U'))
CREATE TABLE legacy_snapshot (
"persistence_id" VARCHAR(255) NOT NULL,
"sequence_number" NUMERIC(10,0) NOT NULL,
@@ -21,4 +16,3 @@ CREATE TABLE legacy_snapshot (
"snapshot" VARBINARY(max) NOT NULL,
PRIMARY KEY ("persistence_id", "sequence_number")
);
-end;
diff --git
a/migrator/src/test/resources/schema/sqlserver/sqlserver-drop-schema-legacy.sql
b/migrator-integration-test/src/test/resources/schema/sqlserver/sqlserver-drop-schema-legacy.sql
similarity index 100%
rename from
migrator/src/test/resources/schema/sqlserver/sqlserver-drop-schema-legacy.sql
rename to
migrator-integration-test/src/test/resources/schema/sqlserver/sqlserver-drop-schema-legacy.sql
diff --git a/migrator/src/test/resources/sqlserver-application.conf
b/migrator-integration-test/src/test/resources/sqlserver-application.conf
similarity index 100%
rename from migrator/src/test/resources/sqlserver-application.conf
rename to
migrator-integration-test/src/test/resources/sqlserver-application.conf
diff --git
a/migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigratorTest.scala
b/migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigratorTest.scala
similarity index 100%
rename from
migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigratorTest.scala
rename to
migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigratorTest.scala
diff --git
a/migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
b/migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
similarity index 99%
rename from
migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
rename to
migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
index 51e22e6..6af8701 100644
---
a/migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
+++
b/migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/MigratorSpec.scala
@@ -342,6 +342,7 @@ object MigratorSpec {
tables.foreach { name =>
withStatement(stmt => stmt.executeUpdate(s"""DELETE FROM "$name"
"""))(db)
}
+ withStatement(stmt => stmt.executeUpdate("""BEGIN
"reset_legacy_sequence"; END; """))(db)
withStatement(stmt => stmt.executeUpdate("""BEGIN "reset_sequence"; END;
"""))(db)
}
diff --git
a/migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigratorTest.scala
b/migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigratorTest.scala
similarity index 100%
rename from
migrator/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigratorTest.scala
rename to
migrator-integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigratorTest.scala
diff --git
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
index 150405b..f67befb 100644
---
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
+++
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
@@ -144,14 +144,12 @@ final case class JournalMigrator(profile:
JdbcProfile)(implicit system: ActorSys
private def writeJournalRowsStatements(
journalSerializedRow: JournalPekkoSerializationRow,
tags: Set[String]): DBIO[Unit] = {
- val journalInsert: DBIO[Long] = newJournalQueries.JournalTable
- .returning(newJournalQueries.JournalTable.map(_.ordering))
- .forceInsert(journalSerializedRow)
-
- val tagInserts =
- newJournalQueries.TagTable ++= tags.map(tag =>
TagRow(journalSerializedRow.ordering, tag)).toSeq
-
- journalInsert.flatMap(_ => tagInserts.asInstanceOf[DBIO[Unit]])
+ for {
+ id <- newJournalQueries.JournalTable
+ .returning(newJournalQueries.JournalTable.map(_.ordering)) +=
journalSerializedRow
+ tagInserts = tags.map(tag => TagRow(id, tag))
+ _ <- newJournalQueries.TagTable ++= tagInserts
+ } yield ()
}
}
diff --git a/migrator/src/test/resources/schema/h2/h2-create-schema.sql
b/migrator/src/test/resources/schema/h2/h2-create-schema.sql
deleted file mode 100644
index ca44e87..0000000
--- a/migrator/src/test/resources/schema/h2/h2-create-schema.sql
+++ /dev/null
@@ -1,56 +0,0 @@
-CREATE TABLE IF NOT EXISTS "event_journal" (
- "ordering" BIGINT UNIQUE NOT NULL AUTO_INCREMENT,
- "deleted" BOOLEAN DEFAULT false NOT NULL,
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" BIGINT NOT NULL,
- "writer" VARCHAR NOT NULL,
- "write_timestamp" BIGINT NOT NULL,
- "adapter_manifest" VARCHAR NOT NULL,
- "event_payload" BLOB NOT NULL,
- "event_ser_id" INTEGER NOT NULL,
- "event_ser_manifest" VARCHAR NOT NULL,
- "meta_payload" BLOB,
- "meta_ser_id" INTEGER,
- "meta_ser_manifest" VARCHAR,
- PRIMARY KEY("persistence_id","sequence_number")
- );
-
-CREATE UNIQUE INDEX "event_journal_ordering_idx" on "event_journal"
("ordering");
-
-CREATE TABLE IF NOT EXISTS "event_tag" (
- "event_id" BIGINT NOT NULL,
- "tag" VARCHAR NOT NULL,
- PRIMARY KEY("event_id", "tag"),
- CONSTRAINT fk_event_journal
- FOREIGN KEY("event_id")
- REFERENCES "event_journal"("ordering")
- ON DELETE CASCADE
-);
-
-CREATE TABLE IF NOT EXISTS "snapshot" (
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" BIGINT NOT NULL,
- "created" BIGINT NOT NULL,"snapshot_ser_id" INTEGER NOT NULL,
- "snapshot_ser_manifest" VARCHAR NOT NULL,
- "snapshot_payload" BLOB NOT NULL,
- "meta_ser_id" INTEGER,
- "meta_ser_manifest" VARCHAR,
- "meta_payload" BLOB,
- PRIMARY KEY("persistence_id","sequence_number")
- );
-
-CREATE SEQUENCE IF NOT EXISTS "global_offset_seq";
-
-CREATE TABLE IF NOT EXISTS "durable_state" (
- "global_offset" BIGINT DEFAULT NEXT VALUE FOR "global_offset_seq",
- "persistence_id" VARCHAR(255) NOT NULL,
- "revision" BIGINT NOT NULL,
- "state_payload" BLOB NOT NULL,
- "state_serial_id" INTEGER NOT NULL,
- "state_serial_manifest" VARCHAR,
- "tag" VARCHAR,
- "state_timestamp" BIGINT NOT NULL,
- PRIMARY KEY("persistence_id")
- );
-CREATE INDEX IF NOT EXISTS "state_tag_idx" on "durable_state" ("tag");
-CREATE INDEX IF NOT EXISTS "state_global_offset_idx" on "durable_state"
("global_offset");
diff --git a/migrator/src/test/resources/schema/h2/h2-drop-schema.sql
b/migrator/src/test/resources/schema/h2/h2-drop-schema.sql
deleted file mode 100644
index f7f02d6..0000000
--- a/migrator/src/test/resources/schema/h2/h2-drop-schema.sql
+++ /dev/null
@@ -1,5 +0,0 @@
-DROP TABLE IF EXISTS PUBLIC."event_tag";
-DROP TABLE IF EXISTS PUBLIC."event_journal";
-DROP TABLE IF EXISTS PUBLIC."snapshot";
-DROP TABLE IF EXISTS PUBLIC."durable_state";
-DROP SEQUENCE IF EXISTS PUBLIC."global_offset_seq";
diff --git a/migrator/src/test/resources/schema/mysql/mysql-create-schema.sql
b/migrator/src/test/resources/schema/mysql/mysql-create-schema.sql
deleted file mode 100644
index 5c57be2..0000000
--- a/migrator/src/test/resources/schema/mysql/mysql-create-schema.sql
+++ /dev/null
@@ -1,38 +0,0 @@
-CREATE TABLE IF NOT EXISTS event_journal(
- ordering SERIAL,
- deleted BOOLEAN DEFAULT false NOT NULL,
- persistence_id VARCHAR(255) NOT NULL,
- sequence_number BIGINT NOT NULL,
- writer TEXT NOT NULL,
- write_timestamp BIGINT NOT NULL,
- adapter_manifest TEXT NOT NULL,
- event_payload BLOB NOT NULL,
- event_ser_id INTEGER NOT NULL,
- event_ser_manifest TEXT NOT NULL,
- meta_payload BLOB,
- meta_ser_id INTEGER,meta_ser_manifest TEXT,
- PRIMARY KEY(persistence_id,sequence_number)
-);
-
-CREATE UNIQUE INDEX event_journal_ordering_idx ON event_journal(ordering);
-
-CREATE TABLE IF NOT EXISTS event_tag (
- event_id BIGINT UNSIGNED NOT NULL,
- tag VARCHAR(255) NOT NULL,
- PRIMARY KEY(event_id, tag),
- FOREIGN KEY (event_id)
- REFERENCES event_journal(ordering)
- ON DELETE CASCADE
- );
-
-CREATE TABLE IF NOT EXISTS snapshot (
- persistence_id VARCHAR(255) NOT NULL,
- sequence_number BIGINT NOT NULL,
- created BIGINT NOT NULL,
- snapshot_ser_id INTEGER NOT NULL,
- snapshot_ser_manifest TEXT NOT NULL,
- snapshot_payload BLOB NOT NULL,
- meta_ser_id INTEGER,
- meta_ser_manifest TEXT,
- meta_payload BLOB,
- PRIMARY KEY (persistence_id, sequence_number));
diff --git a/migrator/src/test/resources/schema/mysql/mysql-drop-schema.sql
b/migrator/src/test/resources/schema/mysql/mysql-drop-schema.sql
deleted file mode 100644
index 750504e..0000000
--- a/migrator/src/test/resources/schema/mysql/mysql-drop-schema.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP TABLE IF EXISTS event_tag;
-DROP TABLE IF EXISTS event_journal;
-DROP TABLE IF EXISTS snapshot;
diff --git
a/migrator/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
b/migrator/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
deleted file mode 100644
index 8cbb059..0000000
--- a/migrator/src/test/resources/schema/oracle/oracle-create-schema-legacy.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-CREATE SEQUENCE "ordering_seq" START WITH 1 INCREMENT BY 1 NOMAXVALUE
-/
-
-CREATE TABLE "journal" (
- "ordering" NUMERIC,
- "deleted" char check ("deleted" in (0,1)) NOT NULL,
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" NUMERIC NOT NULL,
- "tags" VARCHAR(255) DEFAULT NULL,
- "message" BLOB NOT NULL,
- PRIMARY KEY("persistence_id", "sequence_number")
-)
-/
-
-CREATE UNIQUE INDEX "journal_ordering_idx" ON "journal"("ordering")
-/
-
-CREATE OR REPLACE TRIGGER "ordering_seq_trigger"
-BEFORE INSERT ON "journal"
-FOR EACH ROW
-BEGIN
- SELECT "ordering_seq".NEXTVAL INTO :NEW."ordering" FROM DUAL;
-END;
-/
-
-CREATE OR REPLACE PROCEDURE "reset_sequence"
-IS
- l_value NUMBER;
-BEGIN
- EXECUTE IMMEDIATE 'SELECT "ordering_seq".nextval FROM dual' INTO l_value;
- EXECUTE IMMEDIATE 'ALTER SEQUENCE "ordering_seq" INCREMENT BY -' || l_value
|| ' MINVALUE 0';
- EXECUTE IMMEDIATE 'SELECT "ordering_seq".nextval FROM dual' INTO l_value;
- EXECUTE IMMEDIATE 'ALTER SEQUENCE "ordering_seq" INCREMENT BY 1 MINVALUE 0';
-END;
-/
-
-CREATE TABLE "legacy_snapshot" (
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" NUMERIC NOT NULL,
- "created" NUMERIC NOT NULL,
- "snapshot" BLOB NOT NULL,
- PRIMARY KEY ("persistence_id", "sequence_number")
-)
-/
\ No newline at end of file
diff --git a/migrator/src/test/resources/schema/oracle/oracle-create-schema.sql
b/migrator/src/test/resources/schema/oracle/oracle-create-schema.sql
deleted file mode 100644
index dde9275..0000000
--- a/migrator/src/test/resources/schema/oracle/oracle-create-schema.sql
+++ /dev/null
@@ -1,57 +0,0 @@
-CREATE SEQUENCE EVENT_JOURNAL__ORDERING_SEQ START WITH 1 INCREMENT BY 1
NOMAXVALUE
-/
-
-CREATE TABLE EVENT_JOURNAL (
- ORDERING NUMERIC UNIQUE,
- DELETED CHAR(1) DEFAULT 0 NOT NULL check (DELETED in (0, 1)),
- PERSISTENCE_ID VARCHAR(255) NOT NULL,
- SEQUENCE_NUMBER NUMERIC NOT NULL,
- WRITER VARCHAR(255) NOT NULL,
- WRITE_TIMESTAMP NUMBER(19) NOT NULL,
- ADAPTER_MANIFEST VARCHAR(255),
- EVENT_PAYLOAD BLOB NOT NULL,
- EVENT_SER_ID NUMBER(10) NOT NULL,
- EVENT_SER_MANIFEST VARCHAR(255),
- META_PAYLOAD BLOB,
- META_SER_ID NUMBER(10),
- META_SER_MANIFEST VARCHAR(255),
- PRIMARY KEY(PERSISTENCE_ID, SEQUENCE_NUMBER)
- )
-/
-
-CREATE OR REPLACE TRIGGER EVENT_JOURNAL__ORDERING_TRG before insert on
EVENT_JOURNAL REFERENCING NEW AS NEW FOR EACH ROW WHEN (new.ORDERING is null)
begin select EVENT_JOURNAL__ORDERING_seq.nextval into :new.ORDERING from
sys.dual; end;
-/
-
-CREATE TABLE EVENT_TAG (
- EVENT_ID NUMERIC NOT NULL,
- TAG VARCHAR(255) NOT NULL,
- PRIMARY KEY(EVENT_ID, TAG),
- FOREIGN KEY(EVENT_ID) REFERENCES EVENT_JOURNAL(ORDERING)
- ON DELETE CASCADE
- )
-/
-
-CREATE TABLE SNAPSHOT (
- PERSISTENCE_ID VARCHAR(255) NOT NULL,
- SEQUENCE_NUMBER NUMERIC NOT NULL,
- CREATED NUMERIC NOT NULL,
- SNAPSHOT_SER_ID NUMBER(10) NOT NULL,
- SNAPSHOT_SER_MANIFEST VARCHAR(255),
- SNAPSHOT_PAYLOAD BLOB NOT NULL,
- META_SER_ID NUMBER(10),
- META_SER_MANIFEST VARCHAR(255),
- META_PAYLOAD BLOB,
- PRIMARY KEY(PERSISTENCE_ID,SEQUENCE_NUMBER)
- )
-/
-
-CREATE OR REPLACE PROCEDURE "reset_sequence"
-IS
- l_value NUMBER;
-BEGIN
- EXECUTE IMMEDIATE 'SELECT EVENT_JOURNAL__ORDERING_SEQ.nextval FROM dual'
INTO l_value;
- EXECUTE IMMEDIATE 'ALTER SEQUENCE EVENT_JOURNAL__ORDERING_SEQ INCREMENT BY
-' || l_value || ' MINVALUE 0';
- EXECUTE IMMEDIATE 'SELECT EVENT_JOURNAL__ORDERING_SEQ.nextval FROM dual'
INTO l_value;
- EXECUTE IMMEDIATE 'ALTER SEQUENCE EVENT_JOURNAL__ORDERING_SEQ INCREMENT BY 1
MINVALUE 0';
-END;
-/
diff --git
a/migrator/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
b/migrator/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
deleted file mode 100644
index 0d2ef11..0000000
--- a/migrator/src/test/resources/schema/oracle/oracle-drop-schema-legacy.sql
+++ /dev/null
@@ -1,21 +0,0 @@
--- (ddl lock timeout in seconds) this allows tests which are still writing to
the db to finish gracefully
-ALTER SESSION SET ddl_lock_timeout = 150
-/
-
-DROP TABLE "journal" CASCADE CONSTRAINT
-/
-
-DROP TABLE "legacy_snapshot" CASCADE CONSTRAINT
-/
-
-DROP TABLE "deleted_to" CASCADE CONSTRAINT
-/
-
-DROP TRIGGER "ordering_seq_trigger"
-/
-
-DROP PROCEDURE "reset_sequence"
-/
-
-DROP SEQUENCE "ordering_seq"
-/
diff --git a/migrator/src/test/resources/schema/oracle/oracle-drop-schema.sql
b/migrator/src/test/resources/schema/oracle/oracle-drop-schema.sql
deleted file mode 100644
index ed69f1f..0000000
--- a/migrator/src/test/resources/schema/oracle/oracle-drop-schema.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-ALTER SESSION SET ddl_lock_timeout = 15
-/
-
-DROP TABLE EVENT_TAG CASCADE CONSTRAINT
-/
-
-DROP TABLE EVENT_JOURNAL CASCADE CONSTRAINT
-/
-
-DROP TABLE SNAPSHOT CASCADE CONSTRAINT
-/
-
-DROP TABLE SNAPSHOT CASCADE CONSTRAINT
-/
-
-DROP SEQUENCE EVENT_JOURNAL__ORDERING_SEQ
-/
-
-DROP TRIGGER EVENT_JOURNAL__ORDERING_TRG
-/
diff --git
a/migrator/src/test/resources/schema/postgres/postgres-create-schema.sql
b/migrator/src/test/resources/schema/postgres/postgres-create-schema.sql
deleted file mode 100644
index 7ae7e09..0000000
--- a/migrator/src/test/resources/schema/postgres/postgres-create-schema.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-CREATE TABLE IF NOT EXISTS public.event_journal(
- ordering BIGSERIAL,
- persistence_id VARCHAR(255) NOT NULL,
- sequence_number BIGINT NOT NULL,
- deleted BOOLEAN DEFAULT FALSE NOT NULL,
-
- writer VARCHAR(255) NOT NULL,
- write_timestamp BIGINT,
- adapter_manifest VARCHAR(255),
-
- event_ser_id INTEGER NOT NULL,
- event_ser_manifest VARCHAR(255) NOT NULL,
- event_payload BYTEA NOT NULL,
-
- meta_ser_id INTEGER,
- meta_ser_manifest VARCHAR(255),
- meta_payload BYTEA,
-
- PRIMARY KEY(persistence_id, sequence_number)
-);
-
-CREATE UNIQUE INDEX event_journal_ordering_idx ON
public.event_journal(ordering);
-
-CREATE TABLE IF NOT EXISTS public.event_tag(
- event_id BIGINT,
- tag VARCHAR(256),
- PRIMARY KEY(event_id, tag),
- CONSTRAINT fk_event_journal
- FOREIGN KEY(event_id)
- REFERENCES event_journal(ordering)
- ON DELETE CASCADE
-);
-
-CREATE TABLE IF NOT EXISTS public.snapshot (
- persistence_id VARCHAR(255) NOT NULL,
- sequence_number BIGINT NOT NULL,
- created BIGINT NOT NULL,
-
- snapshot_ser_id INTEGER NOT NULL,
- snapshot_ser_manifest VARCHAR(255) NOT NULL,
- snapshot_payload BYTEA NOT NULL,
-
- meta_ser_id INTEGER,
- meta_ser_manifest VARCHAR(255),
- meta_payload BYTEA,
-
- PRIMARY KEY(persistence_id, sequence_number)
-);
-
-CREATE TABLE IF NOT EXISTS public.durable_state (
- global_offset BIGSERIAL,
- persistence_id VARCHAR(255) NOT NULL,
- revision BIGINT NOT NULL,
- state_payload BYTEA NOT NULL,
- state_serial_id INTEGER NOT NULL,
- state_serial_manifest VARCHAR(255),
- tag VARCHAR,
- state_timestamp BIGINT NOT NULL,
- PRIMARY KEY(persistence_id)
- );
-CREATE INDEX CONCURRENTLY state_tag_idx on public.durable_state (tag);
-CREATE INDEX CONCURRENTLY state_global_offset_idx on public.durable_state
(global_offset);
diff --git
a/migrator/src/test/resources/schema/postgres/postgres-drop-schema.sql
b/migrator/src/test/resources/schema/postgres/postgres-drop-schema.sql
deleted file mode 100644
index 01cb9b4..0000000
--- a/migrator/src/test/resources/schema/postgres/postgres-drop-schema.sql
+++ /dev/null
@@ -1,5 +0,0 @@
-DROP TABLE IF EXISTS public.event_tag;
-DROP TABLE IF EXISTS public.event_journal;
-DROP TABLE IF EXISTS public.snapshot;
-DROP TABLE IF EXISTS public.durable_state;
-
diff --git
a/migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema.sql
b/migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema.sql
deleted file mode 100644
index f4cf59f..0000000
--- a/migrator/src/test/resources/schema/sqlserver/sqlserver-create-schema.sql
+++ /dev/null
@@ -1,42 +0,0 @@
-CREATE TABLE event_journal(
- "ordering" BIGINT IDENTITY(1,1) NOT NULL,
- "deleted" BIT DEFAULT 0 NOT NULL,
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" NUMERIC(10,0) NOT NULL,
- "writer" VARCHAR(255) NOT NULL,
- "write_timestamp" BIGINT NOT NULL,
- "adapter_manifest" VARCHAR(MAX) NOT NULL,
- "event_payload" VARBINARY(MAX) NOT NULL,
- "event_ser_id" INTEGER NOT NULL,
- "event_ser_manifest" VARCHAR(MAX) NOT NULL,
- "meta_payload" VARBINARY(MAX),
- "meta_ser_id" INTEGER,
- "meta_ser_manifest" VARCHAR(MAX)
- PRIMARY KEY ("persistence_id", "sequence_number")
-);
-
-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")
- constraint "fk_event_journal"
- foreign key("event_id")
- references "dbo"."event_journal"("ordering")
- on delete CASCADE
-);
-
-CREATE TABLE "snapshot" (
- "persistence_id" VARCHAR(255) NOT NULL,
- "sequence_number" NUMERIC(10,0) NOT NULL,
- "created" BIGINT NOT NULL,
- "snapshot_ser_id" INTEGER NOT NULL,
- "snapshot_ser_manifest" VARCHAR(255) NOT NULL,
- "snapshot_payload" VARBINARY(MAX) NOT NULL,
- "meta_ser_id" INTEGER,
- "meta_ser_manifest" VARCHAR(255),
- "meta_payload" VARBINARY(MAX),
- PRIMARY KEY ("persistence_id", "sequence_number")
- )
-
diff --git
a/migrator/src/test/resources/schema/sqlserver/sqlserver-drop-schema.sql
b/migrator/src/test/resources/schema/sqlserver/sqlserver-drop-schema.sql
deleted file mode 100644
index 750504e..0000000
--- a/migrator/src/test/resources/schema/sqlserver/sqlserver-drop-schema.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP TABLE IF EXISTS event_tag;
-DROP TABLE IF EXISTS event_journal;
-DROP TABLE IF EXISTS snapshot;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]