feat(db): move from Turso/libSQL to Postgres via @profullstack/libsql-pg - #120
Merged
Merged
Conversation
Production reads DATABASE_URL=postgres://... through @profullstack/libsql-pg, which keeps the @libsql/client surface every query here was written against, rewrites the SQLite idioms per statement and runs the CREATE TABLEs in initSchema through its schema converter. Local runs and the tests keep a libSQL file (@libsql/client is now a devDependency, loaded lazily for file: URLs; TURSO_DATABASE_URL still names one). libsql:// is refused with a message pointing at the move. Dialect fixes: the waitlist sort orders by lower(email) instead of COLLATE NOCASE (no such collation in Postgres; same order on both), and addColumnIfMissing also accepts Postgres's "already exists" message. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
ThreatCrush Security Scan20 finding(s) HIGH/CRITICAL: 3 | MEDIUM: 13 | LOW: 4
Snippets are redacted; ThreatCrush never prints matched credential material. |
Postgres returns created_at/expires_at as ISO strings; appending "Z" to one made an Invalid Date, whose getTime() compares as never expired.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second pass of the dev2 migration: the database leaves Turso for the shared Postgres cluster on dev2.
DATABASE_URL=postgres://...is read through@profullstack/libsql-pg(the@libsql/clientsurface; SQLite idioms rewritten per statement; theCREATE TABLEs ininitSchemago through its schema converter, which needed 0.1.3 forDEFAULT 'x' CHECK (...)anddatetime('now','+7 days')defaults).file:still works locally and in the tests (@libsql/clientbecomes a devDependency, loaded lazily;TURSO_DATABASE_URLstill names afile:URL).libsql://is refused with a pointer to the move.lower(email)instead ofCOLLATE NOCASE(Postgres has no such collation; identical order on both).addColumnIfMissingalso accepts Postgres's "already exists" (the client rewrites toADD COLUMN IF NOT EXISTSanyway).next.config.mjs:pgand both drivers stay external.Checks:
bun test tests/253/253,next buildclean.Data:
dev2-site db-create moshcoding.com, schema fromlibsql-pg convert-schema,libsql-pg copy --verify, thenprovision(+env_removefor the Turso settings) anddeploy.🤖 Generated with Claude Code