Skip to content

Commit a460794

Browse files
committed
Move role insertion out of scope of table creation
1 parent 0193b49 commit a460794

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tiled/authn_database/core.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@ async def create_default_roles(db):
7171

7272

7373
async def initialize_database(engine: AsyncEngine) -> None:
74-
async with engine.connect() as conn:
74+
async with engine.begin() as conn:
7575
# Create all tables.
7676
await conn.run_sync(Base.metadata.create_all)
77-
await conn.commit()
78-
79-
# Initialize Roles table.
80-
async with AsyncSession(engine) as db:
81-
await create_default_roles(db)
82-
77+
78+
# Initialize Roles table.
79+
async with AsyncSession(engine) as db:
80+
await create_default_roles(db)
81+
db.commit()
8382

8483
async def purge_expired(db: AsyncSession, cls) -> int:
8584
"""

0 commit comments

Comments
 (0)