Ensure table metadata is passed to Alembic

This commit is contained in:
Spotlight 2024-09-23 22:58:57 -05:00
parent 6c7d738893
commit e54133792c
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
2 changed files with 6 additions and 4 deletions

View File

@ -64,7 +64,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=get_metadata(), literal_binds=True
url=url, literal_binds=True
)
with context.begin_transaction():
@ -98,7 +98,6 @@ def run_migrations_online():
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=get_metadata(),
**conf_args
)

View File

@ -7,7 +7,7 @@ import sys, datetime, xmltodict, pickle, secrets
from sqlalchemy import select, update, insert, delete
from database import start_db_time, get_db_url, Friend, DiscordFriends, Discord, Config
from database import *
sys.path.append('../')
from api.love2 import *
@ -22,7 +22,10 @@ app.config["SQLALCHEMY_DATABASE_URI"] = get_db_url()
db = SQLAlchemy()
db.init_app(app)
migrate = Migrate(app, db)
# We need to manually specify our base model's metadata after
# importing all other models using it as the declarative base.
# (See above with `from database import *`)
migrate = Migrate(app, db, target_metadata=Base.metadata)
limiter = Limiter(app, key_func=lambda: request.access_route[-1])