Skip to content

feat: add versioned database migration system#1060

Merged
confuser merged 5 commits intomasterfrom
feature/migration-runner
Apr 4, 2026
Merged

feat: add versioned database migration system#1060
confuser merged 5 commits intomasterfrom
feature/migration-runner

Conversation

@confuser
Copy link
Copy Markdown
Member

@confuser confuser commented Apr 3, 2026

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//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).

confuser added 5 commits April 3, 2026 23:45
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.
@confuser confuser merged commit 5567c18 into master Apr 4, 2026
18 checks passed
@confuser confuser deleted the feature/migration-runner branch April 4, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant