Add podgrab featureset
This commit is contained in:
parent
095bf52a2f
commit
233dd5b5c0
33 changed files with 2315 additions and 125 deletions
24
init_db.py
24
init_db.py
|
@ -1,13 +1,15 @@
|
|||
from app import create_app
|
||||
from application import create_app
|
||||
from app.models.database import db
|
||||
from app.models.settings import Settings
|
||||
import importlib
|
||||
import os
|
||||
|
||||
app = create_app()
|
||||
|
||||
with app.app_context():
|
||||
# Create all tables
|
||||
db.create_all()
|
||||
|
||||
|
||||
# Check if settings exist, create default if not
|
||||
if not Settings.query.first():
|
||||
default_settings = Settings(
|
||||
|
@ -20,5 +22,19 @@ with app.app_context():
|
|||
db.session.add(default_settings)
|
||||
db.session.commit()
|
||||
print("Created default settings")
|
||||
|
||||
print("Database initialized successfully!")
|
||||
|
||||
# Run all migration scripts
|
||||
print("Running migrations...")
|
||||
migrations_dir = os.path.join(os.path.dirname(__file__), 'migrations')
|
||||
for filename in os.listdir(migrations_dir):
|
||||
if filename.endswith('.py') and filename != '__init__.py':
|
||||
module_name = f"migrations.{filename[:-3]}"
|
||||
try:
|
||||
migration_module = importlib.import_module(module_name)
|
||||
if hasattr(migration_module, 'run_migration'):
|
||||
print(f"Running migration: {filename}")
|
||||
migration_module.run_migration()
|
||||
except Exception as e:
|
||||
print(f"Error running migration {filename}: {str(e)}")
|
||||
|
||||
print("Database initialized successfully!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue