1
- from logging .config import fileConfig
1
+ from logging .config import fileConfig # isort:skip
2
2
3
- from main import Hero
4
- from sqlmodel import SQLModel
3
+ from main import Hero # isort:skip
4
+ from sqlmodel import SQLModel # isort:skip
5
5
6
- from sqlalchemy import engine_from_config
7
- from sqlalchemy import pool
6
+ from sqlalchemy import engine_from_config # isort:skip
7
+ from sqlalchemy import pool # isort:skip
8
8
9
- from alembic import context
9
+ from alembic import context # isort:skip
10
10
11
11
# this is the Alembic Config object, which provides
12
12
# access to the values within the .ini file in use.
32
32
33
33
def run_migrations_offline () -> None :
34
34
"""Run migrations in 'offline' mode.
35
-
36
35
This configures the context with just a URL
37
36
and not an Engine, though an Engine is acceptable
38
37
here as well. By skipping the Engine creation
39
38
we don't even need a DBAPI to be available.
40
-
41
39
Calls to context.execute() here emit the given string to the
42
40
script output.
43
-
44
41
"""
45
42
url = config .get_main_option ("sqlalchemy.url" )
46
43
context .configure (
@@ -56,10 +53,8 @@ def run_migrations_offline() -> None:
56
53
57
54
def run_migrations_online () -> None :
58
55
"""Run migrations in 'online' mode.
59
-
60
56
In this scenario we need to create an Engine
61
57
and associate a connection with the context.
62
-
63
58
"""
64
59
connectable = engine_from_config (
65
60
config .get_section (config .config_ini_section ),
@@ -68,9 +63,7 @@ def run_migrations_online() -> None:
68
63
)
69
64
70
65
with connectable .connect () as connection :
71
- context .configure (
72
- connection = connection , target_metadata = target_metadata
73
- )
66
+ context .configure (connection = connection , target_metadata = target_metadata )
74
67
75
68
with context .begin_transaction ():
76
69
context .run_migrations ()
0 commit comments