Add ALTER TABLE migration for auto_signup column on existing ClickHouse
The CREATE TABLE IF NOT EXISTS won't add new columns to an existing table. Add 05-oidc-auto-signup.sql with ALTER TABLE ADD COLUMN IF NOT EXISTS and register it in ClickHouseConfig startup schema + test init. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,8 @@ public class ClickHouseConfig {
|
||||
private static final Logger log = LoggerFactory.getLogger(ClickHouseConfig.class);
|
||||
private static final String[] SCHEMA_FILES = {
|
||||
"clickhouse/01-schema.sql", "clickhouse/02-search-columns.sql",
|
||||
"clickhouse/03-users.sql", "clickhouse/04-oidc-config.sql"
|
||||
"clickhouse/03-users.sql", "clickhouse/04-oidc-config.sql",
|
||||
"clickhouse/05-oidc-auto-signup.sql"
|
||||
};
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS oidc_config (
|
||||
client_secret String DEFAULT '',
|
||||
roles_claim String DEFAULT 'realm_access.roles',
|
||||
default_roles Array(LowCardinality(String)),
|
||||
auto_signup Bool DEFAULT true,
|
||||
updated_at DateTime64(3, 'UTC') DEFAULT now64(3, 'UTC')
|
||||
) ENGINE = ReplacingMergeTree(updated_at)
|
||||
ORDER BY (config_id);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE oidc_config ADD COLUMN IF NOT EXISTS auto_signup Bool DEFAULT true;
|
||||
@@ -56,7 +56,7 @@ public abstract class AbstractClickHouseIT {
|
||||
}
|
||||
|
||||
// Load all schema files in order
|
||||
String[] schemaFiles = {"01-schema.sql", "02-search-columns.sql", "03-users.sql", "04-oidc-config.sql"};
|
||||
String[] schemaFiles = {"01-schema.sql", "02-search-columns.sql", "03-users.sql", "04-oidc-config.sql", "05-oidc-auto-signup.sql"};
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(
|
||||
CLICKHOUSE.getJdbcUrl(),
|
||||
|
||||
1
clickhouse/init/05-oidc-auto-signup.sql
Normal file
1
clickhouse/init/05-oidc-auto-signup.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE oidc_config ADD COLUMN IF NOT EXISTS auto_signup Bool DEFAULT true;
|
||||
Reference in New Issue
Block a user