Update settings/admin UI and misc fixes
This commit is contained in:
12
app/cli.py
12
app/cli.py
@@ -2,7 +2,7 @@ import click
|
||||
from flask.cli import with_appcontext
|
||||
|
||||
from .extensions import db
|
||||
from .models import User
|
||||
from .models import AppSettings, User
|
||||
|
||||
|
||||
@click.command("init-db")
|
||||
@@ -36,10 +36,20 @@ def init_db_command(admin_email: str, admin_pass: str):
|
||||
if "storage_max_bytes" not in company_cols:
|
||||
db.session.execute(db.text("ALTER TABLE company ADD COLUMN storage_max_bytes BIGINT"))
|
||||
db.session.commit()
|
||||
|
||||
settings_cols = [r[1] for r in db.session.execute(db.text("PRAGMA table_info(app_settings)")).fetchall()]
|
||||
if settings_cols and "public_domain" not in settings_cols:
|
||||
db.session.execute(db.text("ALTER TABLE app_settings ADD COLUMN public_domain VARCHAR(255)"))
|
||||
db.session.commit()
|
||||
except Exception:
|
||||
# Best-effort; if it fails we continue so fresh DBs still work.
|
||||
db.session.rollback()
|
||||
|
||||
# Ensure AppSettings row exists.
|
||||
if not db.session.get(AppSettings, 1):
|
||||
db.session.add(AppSettings(id=1))
|
||||
db.session.commit()
|
||||
|
||||
admin_email = (admin_email or "").strip().lower()
|
||||
if not admin_email:
|
||||
raise click.UsageError("--admin-email is required")
|
||||
|
||||
Reference in New Issue
Block a user