Replies: 4 comments 12 replies
-
Is this implying support for swapping out the ORM? this seems dangerous for projects such as StudioCMS 😅 where we rely HEAVILY on the specific layout of the
Is it also part of the goal to allow hot-swapping the database backend while maintaining functionality using the same functions without tweaking? (obviously talking about the more basic select, insert, batch type functions. |
Beta Was this translation helpful? Give feedback.
-
Ideally I think it would be great if things like db urls could use |
Beta Was this translation helpful? Give feedback.
-
Related: #1147 |
Beta Was this translation helpful? Give feedback.
-
I wonder if it would make sense for it to ship with sqlite local file only by default as now there is no connection to turso |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
This proposal defines an interface (
DatabaseBackend
) allowing third-party integrations to provide alternative database backends for Astro DB. This decouples Astro DB's schema management, migration tooling, and ORM integration from its current default LibSQL implementation, enabling users to leverage various database providers while benefiting from the Astro DB developer experience.Background & Motivation
Astro DB currently integrates tightly with LibSQL. While LibSQL provides a good default experience, its primary hosted offering comes from a single provider (Turso). Users wishing to use other managed database services (e.g., Neon, PlanetScale, Supabase, provider-specific offerings on Vercel/Netlify) or self-hosted databases other than LibSQL cannot leverage Astro DB's streamlined schema management and ORM features. They are forced to either use Turso, self-host LibSQL (which can be complex), or forgo Astro DB entirely.
Since the shutdown of Astro Studio (Astro's own hosted LibSQL service), Astro DB only supports open database connections. This presents a natural opportunity to fulfill a common community request: allowing users to bring their own database backend.
Decoupling the backend will:
Goals
DatabaseBackend
interface that third-party integrations can implement to provide database support for Astro DB.db/config.ts
,astro:db
CLI commands for migrations, ORM generation viaastro:db/runtime
) to function correctly with any compliant backend adapter.astro.config.mjs
file.Non-Goals
db/config.ts
,db/seed.ts
).Example
User Configuration (
astro.config.mjs
)Users would select and configure their desired backend within the
astroDB
integration options:Implementation Details / Open Questions
A core part of this RFC is defining the
DatabaseBackend
interface. I have considered two approaches as viable so far.The names of method and types are entirely up for discussion.
Option 1: Simplified Interface
The adapter is responsible for the high-level logic of applying schema differences.
Option 2: Granular Operations Interface
Astro DB retains the high-level logic for determining when to create, alter, or drop tables, and the adapter provides factories for generating the specific operations (e.g., SQL statements, API calls) for its database.
Beta Was this translation helpful? Give feedback.
All reactions