Skip to content

Commit

Permalink
chore: add schema in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Oct 27, 2023
1 parent 013d5cd commit 927fd73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions icon_stats/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from logging.config import fileConfig

from sqlalchemy.ext.asyncio import AsyncEngine
from sqlmodel import SQLModel, create_engine
from sqlmodel import SQLModel, create_engine, text

from alembic import context

from icon_stats.db import ASYNC_CONNECTION_STRING

# Imports
from icon_stats.models.cmc_cryptocurrency_quotes_latest import CmcListingsLatestQuote # noqa
from icon_stats.models.cmc_cryptocurrency_quotes_latest import \
CmcListingsLatestQuote # noqa

config = context.config
config.set_main_option("sqlalchemy.url", ASYNC_CONNECTION_STRING)
Expand Down Expand Up @@ -40,6 +41,9 @@ def do_run_migrations(connection):
include_name=include_name,
)

# Make sure the schema exists
connection.execute(text('CREATE SCHEMA IF NOT EXISTS stats'))

with context.begin_transaction():
context.run_migrations()

Expand Down

0 comments on commit 927fd73

Please sign in to comment.