mirror of
https://github.com/creyD/apilog.git
synced 2026-04-12 19:30:29 +02:00
21 lines
580 B
Python
21 lines
580 B
Python
import os
|
|
|
|
from creyPY.fastapi.db.session import SQLALCHEMY_DATABASE_URL, name
|
|
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
from app.services.db.session import create_if_not_exists
|
|
|
|
|
|
def setup(db_name=name):
|
|
# Create Database
|
|
create_if_not_exists(db_name)
|
|
|
|
# Make alembic migrations
|
|
config = Config()
|
|
config.set_main_option("sqlalchemy.url", SQLALCHEMY_DATABASE_URL + db_name)
|
|
config.set_main_option(
|
|
"script_location", os.path.join(os.path.dirname(os.path.dirname(__file__)), "alembic")
|
|
)
|
|
command.upgrade(config, "head")
|