feat(g0v0-migrate): implement g0v0 migration system with plugin support (#97)

For details please view the PR.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
MingxuanGame
2025-12-13 17:56:34 +08:00
committed by GitHub
parent 511150cc4c
commit bb181d930a
13 changed files with 749 additions and 4 deletions

View File

@@ -31,6 +31,12 @@ target_metadata = SQLModel.metadata
# ... etc.
def include_object(object, name, type_, reflected, compare_to) -> bool: # noqa: ARG001
if type_ != "table":
return True
return not name.endswith("alembic_version") and not name.startswith("plugin_")
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
@@ -44,13 +50,13 @@ def run_migrations_offline() -> None:
"""
url = settings.database_url
print(url)
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
compare_type=True,
dialect_opts={"paramstyle": "named"},
include_object=include_object,
)
with context.begin_transaction():
@@ -58,7 +64,12 @@ def run_migrations_offline() -> None:
def do_run_migrations(connection: Connection) -> None:
context.configure(connection=connection, target_metadata=target_metadata, compare_type=True)
context.configure(
connection=connection,
target_metadata=target_metadata,
compare_type=True,
include_object=include_object,
)
with context.begin_transaction():
context.run_migrations()