dev #4
@@ -40,22 +40,33 @@ def _rand_join_code(n: int = 6) -> str:
|
|||||||
|
|
||||||
def _has_column(db: Session, table: str, col: str) -> bool:
|
def _has_column(db: Session, table: str, col: str) -> bool:
|
||||||
"""
|
"""
|
||||||
SQLite + Postgres friendly check.
|
Postgres + SQLite friendly check without spamming Postgres logs.
|
||||||
We use a pragma first (SQLite), fallback to information_schema.
|
- SQLite: PRAGMA table_info
|
||||||
|
- Postgres: information_schema
|
||||||
"""
|
"""
|
||||||
|
dialect = None
|
||||||
try:
|
try:
|
||||||
rows = db.execute(text(f"PRAGMA table_info({table})")).all()
|
dialect = db.get_bind().dialect.name # "postgresql" | "sqlite" | ...
|
||||||
return any(r[1] == col for r in rows) # pragma: column name is at index 1
|
|
||||||
except Exception:
|
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:
|
try:
|
||||||
rows = db.execute(
|
rows = db.execute(
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
SELECT column_name
|
SELECT 1
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
WHERE table_name = :t AND column_name = :c
|
WHERE table_name = :t AND column_name = :c
|
||||||
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
{"t": table, "c": col},
|
{"t": table, "c": col},
|
||||||
@@ -66,6 +77,7 @@ WHERE table_name = :t AND column_name = :c
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _auto_migrate(db: Session):
|
def _auto_migrate(db: Session):
|
||||||
"""
|
"""
|
||||||
Very small, pragmatic auto-migration (no alembic).
|
Very small, pragmatic auto-migration (no alembic).
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export const styles = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
topBar: {
|
topBar: {
|
||||||
|
position: "relative",
|
||||||
|
zIndex: 50,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@@ -153,6 +155,8 @@ export const styles = {
|
|||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
adminWrap: {
|
adminWrap: {
|
||||||
|
position: "relative",
|
||||||
|
zIndex: 1,
|
||||||
marginTop: 14,
|
marginTop: 14,
|
||||||
padding: 12,
|
padding: 12,
|
||||||
borderRadius: 16,
|
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))",
|
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)",
|
boxShadow: "0 18px 55px rgba(0,0,0,0.70)",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
zIndex: 10000,
|
zIndex: 99999,
|
||||||
backdropFilter: "blur(8px)",
|
backdropFilter: "blur(8px)",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user