Skip to content

Commit 18063be

Browse files
committed
⬆️ fix: alembic>=1.16
1 parent 0f8a3cd commit 18063be

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

nonebot_plugin_orm/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def orm(ctx: click.Context, config: Path, name: str, **_) -> None:
6363
options,
6464
)
6565

66-
ctx.obj = AlembicConfig(config, name, cmd_opts=cmd_opts)
66+
ctx.obj = AlembicConfig(config, ini_section=name, cmd_opts=cmd_opts)
6767

6868
ctx.call_on_close(ctx.obj.close)
6969

nonebot_plugin_orm/exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class CommandError(ClickException, util.CommandError):
66
pass
77

88

9-
class AutogenerateDiffsDetected(CommandError, util.AutogenerateDiffsDetected):
9+
class AutogenerateDiffsDetected(util.AutogenerateDiffsDetected, CommandError):
1010
pass

nonebot_plugin_orm/migrate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class AlembicConfig(Config):
8080
def __init__(
8181
self,
8282
file_: str | os.PathLike[str] | None = None,
83+
toml_file: str | os.PathLike[str] | None = None,
8384
ini_section: str = "alembic",
8485
output_buffer: TextIO | None = None,
8586
stdout: TextIO = sys.stdout,
@@ -114,6 +115,7 @@ def __init__(
114115

115116
super().__init__(
116117
file_,
118+
toml_file,
117119
ini_section,
118120
output_buffer,
119121
stdout,
@@ -189,7 +191,7 @@ def move_script(self, script: Script) -> Path:
189191
return script_path
190192

191193
version_location.mkdir(parents=True, exist_ok=True)
192-
return shutil.move(script.path, version_location)
194+
return Path(shutil.move(script.path, version_location))
193195

194196
def _add_post_write_hook(self, name: str, **kwargs: str) -> None:
195197
self.set_section_option(
@@ -564,7 +566,9 @@ def retrieve_migrations(
564566
migration_script = revision_context.generated_revisions[-1]
565567
diffs = cast(UpgradeOps, migration_script.upgrade_ops).as_diffs()
566568
if diffs:
567-
raise AutogenerateDiffsDetected(f"检测到新的升级操作:\n{pformat(diffs)}")
569+
raise AutogenerateDiffsDetected(
570+
f"检测到新的升级操作:\n{pformat(diffs)}", revision_context, diffs
571+
)
568572
else:
569573
config.print_stdout("没有检测到新的升级操作")
570574

pdm.lock

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
{ name = "ProgramRipper", email = "[email protected]" },
88
]
99
dependencies = [
10-
"alembic~=1.13,<1.15",
10+
"alembic~=1.16",
1111
"click~=8.1",
1212
"importlib-metadata>=4.6; python_version < \"3.10\"",
1313
"importlib-resources>=5.12; python_version < \"3.12\"",

0 commit comments

Comments
 (0)