Fix Postgres startup: add xui_email before creating its index.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+4
-7
@@ -77,13 +77,10 @@ def init_schema():
|
|||||||
stmt = '\n'.join(lines).strip()
|
stmt = '\n'.join(lines).strip()
|
||||||
if stmt:
|
if stmt:
|
||||||
cur.execute(stmt)
|
cur.execute(stmt)
|
||||||
conn.commit()
|
|
||||||
# Soft migrations for existing databases
|
# Soft migrations: CREATE TABLE IF NOT EXISTS does not add new columns
|
||||||
with pool.connection() as conn:
|
# to existing tables, so alter after base schema is applied.
|
||||||
with conn.cursor() as cur:
|
cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS xui_email TEXT")
|
||||||
cur.execute(
|
|
||||||
"ALTER TABLE users ADD COLUMN IF NOT EXISTS xui_email TEXT"
|
|
||||||
)
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"CREATE INDEX IF NOT EXISTS idx_users_xui_email ON users(xui_email)"
|
"CREATE INDEX IF NOT EXISTS idx_users_xui_email ON users(xui_email)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ CREATE TABLE IF NOT EXISTS users (
|
|||||||
share_password_hash TEXT
|
share_password_hash TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_users_xui_email ON users(xui_email);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS user_connections (
|
CREATE TABLE IF NOT EXISTS user_connections (
|
||||||
id UUID PRIMARY KEY,
|
id UUID PRIMARY KEY,
|
||||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
|||||||
Reference in New Issue
Block a user