Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail fast in Registry v3 when detecting a v2 DB #4306

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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