File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -85,17 +85,7 @@ async def apply_migrations(seed_db) -> Generator:
85
85
86
86
async with async_engine .connect () as async_conn :
87
87
88
- async_session = sessionmaker (
89
- async_engine ,
90
- expire_on_commit = False ,
91
- class_ = AsyncSession ,
92
- )
93
-
94
- # seed the database
95
- async with async_session () as session :
96
- async with session .begin ():
97
- session .add_all (seed_db )
98
-
88
+ # create a test db
99
89
await async_conn .run_sync (create_database (TEST_DATABASE ))
100
90
# use sqlalchemy ddl for initial table setup
101
91
await async_conn .run_sync (Base .metadata .create_all )
@@ -109,6 +99,15 @@ async def apply_migrations(seed_db) -> Generator:
109
99
)
110
100
# apply migrations
111
101
await alembic .command .upgrade (config , "head" )
102
+ # seed the database
103
+ async_session = sessionmaker (
104
+ async_engine ,
105
+ expire_on_commit = False ,
106
+ class_ = AsyncSession ,
107
+ )
108
+ async with async_session () as session :
109
+ async with session .begin ():
110
+ session .add_all (seed_db )
112
111
113
112
yield
114
113
You can’t perform that action at this time.
0 commit comments