Improve database column check and update frontend z-index styling
Enhanced the `_has_column` function to handle database dialects cleanly, reducing unnecessary PostgreSQL logs. Adjusted frontend z-index values to ensure proper element stacking in the UI.
This commit is contained in:
@@ -40,22 +40,33 @@ def _rand_join_code(n: int = 6) -> str:
|
||||
|
||||
def _has_column(db: Session, table: str, col: str) -> bool:
|
||||
"""
|
||||
SQLite + Postgres friendly check.
|
||||
We use a pragma first (SQLite), fallback to information_schema.
|
||||
Postgres + SQLite friendly check without spamming Postgres logs.
|
||||
- SQLite: PRAGMA table_info
|
||||
- Postgres: information_schema
|
||||
"""
|
||||
dialect = None
|
||||
try:
|
||||
rows = db.execute(text(f"PRAGMA table_info({table})")).all()
|
||||
return any(r[1] == col for r in rows) # pragma: column name is at index 1
|
||||
dialect = db.get_bind().dialect.name # "postgresql" | "sqlite" | ...
|
||||
except Exception:
|
||||
db.rollback()
|
||||
dialect = None
|
||||
|
||||
if dialect == "sqlite":
|
||||
try:
|
||||
rows = db.execute(text(f"PRAGMA table_info({table})")).all()
|
||||
return any(r[1] == col for r in rows)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return False
|
||||
|
||||
# default: Postgres (or others) via information_schema
|
||||
try:
|
||||
rows = db.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT column_name
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = :t AND column_name = :c
|
||||
LIMIT 1
|
||||
"""
|
||||
),
|
||||
{"t": table, "c": col},
|
||||
@@ -64,6 +75,7 @@ WHERE table_name = :t AND column_name = :c
|
||||
except Exception:
|
||||
db.rollback()
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def _auto_migrate(db: Session):
|
||||
|
||||
@@ -16,6 +16,8 @@ export const styles = {
|
||||
},
|
||||
|
||||
topBar: {
|
||||
position: "relative",
|
||||
zIndex: 50,
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
@@ -153,6 +155,8 @@ export const styles = {
|
||||
|
||||
// Admin
|
||||
adminWrap: {
|
||||
position: "relative",
|
||||
zIndex: 1,
|
||||
marginTop: 14,
|
||||
padding: 12,
|
||||
borderRadius: 16,
|
||||
@@ -471,7 +475,7 @@ export const styles = {
|
||||
background: "linear-gradient(180deg, rgba(20,20,24,0.96), rgba(12,12,14,0.92))",
|
||||
boxShadow: "0 18px 55px rgba(0,0,0,0.70)",
|
||||
overflow: "hidden",
|
||||
zIndex: 10000,
|
||||
zIndex: 99999,
|
||||
backdropFilter: "blur(8px)",
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user