Skip to content

feat: add auto-migrations on startup#1711

Merged
Kenshiin13 merged 7 commits intodevfrom
migration
Aug 31, 2025
Merged

feat: add auto-migrations on startup#1711
Kenshiin13 merged 7 commits intodevfrom
migration

Conversation

@Kenshiin13
Copy link
Copy Markdown
Contributor

Description

Introduces a migration system for ESX that allows adding database migrations for older versions.
Includes a new migration for v1.13.3 that adds a unique ssn column to the users table, backfills existing users, and ensures the column is NOT NULL.


Motivation

Previously, migrating users between ESX versions required manual SQL updates and ad-hoc scripts, which was error-prone and time-consuming.
This new system standardizes migrations, allows safe execution, and can be extended to handle migrations for any older ESX version.


Implementation Details

  • Migrations are registered in a Migrations table keyed by ESX version.
  • Each migration is a Lua function that executes SQL updates and any necessary data transformations.
  • The runner iterates through all migrations for a given version and executes them.
  • Each completed migration is tracked using GetResourceKvpInt to avoid re-running on server restart.

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@Kenshiin13 Kenshiin13 merged commit 6d73946 into dev Aug 31, 2025
2 checks passed
@Kenshiin13 Kenshiin13 deleted the migration branch August 31, 2025 13:18
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