Already planed? : about preparing schema and migration #210
Replies: 3 comments 1 reply
-
I'm not sure I understand what you are asking but if you are asking, can you predefine the schema and data and load pglite directory onto an existing database, then yes, at least according to the documentation! https://pglite.dev/docs/api#dumpdatadir With this you can create a postgres datadir and then just supply a tar.gz of that to your new instance. |
Beta Was this translation helpful? Give feedback.
-
Hey @PorcoRosso85 Good question, we don't have any standard schema migration tooling built in (yet). The easers is to just run you migrations immediately after starting PGLite: const pg = await PGlite.create()
pg.exec(`
CREATE TABLE IF NOT EXIST my_table (
-- ... schema
)
CREATE TABLE IF NOT EXIST my_other_table (
-- ... schema
)
`)
// Now you can use the db There are many tools that do schema migration in different ways, and with ORMd such a Drizzle supporting PGlite, using their migration tooling is likely to be preferred in most cases. However, I am considering a basic migration plugin modelled on @databases/pg-migrations, but this is fairly low down the priority list. It is like better served by the community. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. @AntonOfTheWoods @samwillis @AntonOfTheWoods
|
Beta Was this translation helpful? Give feedback.
-
From reading the documentation, it is assumed that the schema is defined after the application is launched.
If I don't use 'electricSQL', is there an option planned for this Repository or project to provide the files after the schema definition or migration in advance?
(I assume this is not a solution of the nature I am asking, but I am sure there will be developers who will have the same question) (apologies if this has already been answered)
Beta Was this translation helpful? Give feedback.
All reactions