Fix: move expires_at migration before index creation
This commit is contained in:
parent
47e2f51eb9
commit
edf5db2499
1 changed files with 5 additions and 5 deletions
|
|
@ -59,11 +59,6 @@ def init_db():
|
||||||
expires_at REAL
|
expires_at REAL
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
db.execute("CREATE INDEX IF NOT EXISTS idx_slug ON pastes(slug)")
|
|
||||||
db.execute("CREATE INDEX IF NOT EXISTS idx_created ON pastes(created_at)")
|
|
||||||
db.execute("CREATE INDEX IF NOT EXISTS idx_expires ON pastes(expires_at)")
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
# Migrate: add expires_at column if missing (existing installs)
|
# Migrate: add expires_at column if missing (existing installs)
|
||||||
cols = [row[1] for row in db.execute("PRAGMA table_info(pastes)").fetchall()]
|
cols = [row[1] for row in db.execute("PRAGMA table_info(pastes)").fetchall()]
|
||||||
if "expires_at" not in cols:
|
if "expires_at" not in cols:
|
||||||
|
|
@ -75,6 +70,11 @@ def init_db():
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
db.execute("CREATE INDEX IF NOT EXISTS idx_slug ON pastes(slug)")
|
||||||
|
db.execute("CREATE INDEX IF NOT EXISTS idx_created ON pastes(created_at)")
|
||||||
|
db.execute("CREATE INDEX IF NOT EXISTS idx_expires ON pastes(expires_at)")
|
||||||
|
db.commit()
|
||||||
|
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
def generate_slug(length=8):
|
def generate_slug(length=8):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue