feat: add versioned database migration system#1060
Merged
Conversation
Replace inline ALTER TABLE/CREATE INDEX blocks scattered across 29
Storage constructors with a centralised MigrationRunner that applies
versioned SQL files from classpath manifests.
Key capabilities:
- Manifest-based migration discovery (db/<scope>/migrations.list)
- Configurable table name placeholders (${tableName})
- MySQL/MariaDB advisory locking for concurrent server startups
- Connection pinning to ensure lock/SQL/unlock on same connection
- Fresh-install detection (skip SQL, mark latest version)
- Existing-install baseline (mark V1 without re-running)
- Idempotent DDL (individual statement failures logged, not fatal)
- Separate local/global scopes with shared bm_schema_version table
- ClassLoader parameter for addon JAR resource loading
Also removes StorageUtils.convertIpColumn() (IPv6 migration).
…ance isolation Instances sharing the same database but using different table prefixes now track migrations independently (e.g. "local:bm_players" vs "local:bm_s2_players") instead of colliding on a bare "local" scope.
Replaces the detection-table-name-derived scope with an opt-in instanceId config field. This avoids scope breakage when admins rename tables, while still supporting shared-database setups.
- Close CompiledStatement and DatabaseResults in finally blocks to prevent resource leaks under load - Add 'lenient' flag to manifest format; only lenient migrations continue on individual statement failures, strict migrations abort - Mark V1 baselines as lenient (idempotent DDL), future V2+ migrations default to strict - Use instanceScope consistently in all log messages - Remove unused SchemaVersion constructor
Global databases are shared by design — all instances should use the same migration scope so migrations aren't applied redundantly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace inline ALTER TABLE/CREATE INDEX blocks scattered across 29 Storage constructors with a centralised MigrationRunner that applies versioned SQL files from classpath manifests.
Key capabilities:
Also removes StorageUtils.convertIpColumn() (IPv6 migration).