Skip to content

Commit

Permalink
Fail fast in v3 when detecting a v2 DB
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Feb 7, 2024
1 parent 589bf9c commit e2c7502
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ private boolean isDatabaseCurrent(Handle handle) {
log.info("Checking to see if the DB is up-to-date.");
log.info("Build's DB version is {}", DB_VERSION);
int version = this.getDatabaseVersion(handle);

// Fast-fail if we try to run Registry v3 against a v2 DB.
// TODO how to do this for kafkasql??
if (version < 100) {
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.";
log.error("--------------------------");
log.error(message);
log.error("--------------------------");
throw new RuntimeException(message);
}
return version == DB_VERSION;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
100
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

CREATE TABLE sequences (name VARCHAR(32) NOT NULL, seq_value BIGINT NOT NULL);
ALTER TABLE sequences ADD PRIMARY KEY (name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

-- TODO: Different column name in h2
CREATE TABLE sequences (name NVARCHAR(32) NOT NULL, value BIGINT NOT NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

0 comments on commit e2c7502

Please sign in to comment.