A from-scratch atproto PDS implementation in Python (mirrors https://github.com/DavidBuchanan314/millipds)
Something went wrong. Try again.
897 B · 45 lines
Python
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546# TODO: some smarter way of handling migrations
import apswimport apsw.bestpractice
apsw.bestpractice.apply(apsw.bestpractice.recommended)
from millipds import static_config
def migrate(con: apsw.Connection): version_now, *_ = con.execute("SELECT db_version FROM config").fetchone()
assert version_now == 1
con.execute( """ CREATE TABLE did_cache( did TEXT PRIMARY KEY NOT NULL, doc BLOB, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL ) STRICT, WITHOUT ROWID """ )
con.execute( """ CREATE TABLE handle_cache( handle TEXT PRIMARY KEY NOT NULL, did TEXT, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL ) STRICT, WITHOUT ROWID """ )
con.execute("UPDATE config SET db_version=2")
if __name__ == "__main__": with apsw.Connection(static_config.MAIN_DB_PATH) as con: migrate(con)
print("v1 -> v2 Migration successful")