Fix: Migration
oidc_jwks_keys table doesn't exist uix_org_provider_type constraint multiple use transaction abort/never rolled back
This commit is contained in:
+16
-3
@@ -1,7 +1,10 @@
|
||||
"""Initialize database script."""
|
||||
from gatehouse_app import create_app
|
||||
from gatehouse_app.extensions import db
|
||||
from sqlalchemy import text
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import time
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
@@ -9,10 +12,20 @@ load_dotenv()
|
||||
# Create application
|
||||
app = create_app()
|
||||
|
||||
import gatehouse_app.models
|
||||
|
||||
with app.app_context():
|
||||
# Drop all tables
|
||||
print("Dropping all tables...")
|
||||
db.drop_all()
|
||||
# Drop all tables, constraints, and indexes cleanly
|
||||
db_url = os.getenv("DATABASE_URL", "")
|
||||
db_name = db_url.split("/")[-1] if db_url else "gatehouse_db"
|
||||
print(f"⚠️ WARNING: About to drop all tables in database '{db_name}'!")
|
||||
print("Countdown to deletion:")
|
||||
for i in range(5, 0, -1):
|
||||
print(f"{i}...")
|
||||
time.sleep(1)
|
||||
db.session.execute(text("DROP SCHEMA public CASCADE"))
|
||||
db.session.execute(text("CREATE SCHEMA public"))
|
||||
db.session.commit()
|
||||
|
||||
# Create all tables
|
||||
print("Creating all tables...")
|
||||
|
||||
Reference in New Issue
Block a user