Skip to content

Commit a8c5c03

Browse files
authored
Fail fast in v3 when detecting a v2 DB (#4306)
1 parent b5d571f commit a8c5c03

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java

+10
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ private boolean isDatabaseCurrent(Handle handle) {
280280
log.info("Checking to see if the DB is up-to-date.");
281281
log.info("Build's DB version is {}", DB_VERSION);
282282
int version = this.getDatabaseVersion(handle);
283+
284+
// Fast-fail if we try to run Registry v3 against a v2 DB.
285+
// TODO how to do this for kafkasql??
286+
if (version < 100) {
287+
String message = "[Apicurio Registry 3.x] Detected legacy 2.x database. Automatic upgrade from 2.x to 3.x is not supported. Please see documentation for migration instructions.";
288+
log.error("--------------------------");
289+
log.error(message);
290+
log.error("--------------------------");
291+
throw new RuntimeException(message);
292+
}
283293
return version == DB_VERSION;
284294
}
285295

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
100

app/src/main/resources/io/apicurio/registry/storage/impl/sql/h2.ddl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
CREATE TABLE apicurio (prop_name VARCHAR(255) NOT NULL, prop_value VARCHAR(255));
66
ALTER TABLE apicurio ADD PRIMARY KEY (prop_name);
7-
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 1);
7+
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 100);
88

99
CREATE TABLE sequences (name VARCHAR(32) NOT NULL, seq_value BIGINT NOT NULL);
1010
ALTER TABLE sequences ADD PRIMARY KEY (name);

app/src/main/resources/io/apicurio/registry/storage/impl/sql/mssql.ddl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
CREATE TABLE apicurio (prop_name NVARCHAR(255) NOT NULL, prop_value NVARCHAR(255));
66
ALTER TABLE apicurio ADD PRIMARY KEY (prop_name);
7-
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 1);
7+
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 100);
88

99
-- TODO: Different column name in h2
1010
CREATE TABLE sequences (name NVARCHAR(32) NOT NULL, value BIGINT NOT NULL);

app/src/main/resources/io/apicurio/registry/storage/impl/sql/postgresql.ddl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
CREATE TABLE apicurio (prop_name VARCHAR(255) NOT NULL, prop_value VARCHAR(255));
66
ALTER TABLE apicurio ADD PRIMARY KEY (prop_name);
7-
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 1);
7+
INSERT INTO apicurio (prop_name, prop_value) VALUES ('db_version', 100);
88

99
-- TODO: Different column name in h2
1010
CREATE TABLE sequences (name VARCHAR(32) NOT NULL, value BIGINT NOT NULL);

0 commit comments

Comments
 (0)