kempo 4.5.5 → 4.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/db/index.js +14 -0
package/package.json
CHANGED
package/server/db/index.js
CHANGED
|
@@ -34,6 +34,20 @@ if(process.env.KEMPO_DB === 'pglite'){
|
|
|
34
34
|
import('drizzle-orm/pglite'),
|
|
35
35
|
import('drizzle-kit/api')
|
|
36
36
|
]);
|
|
37
|
+
/*
|
|
38
|
+
A project's drizzle.config.js lists every schema its database holds (its own, kempo's and any
|
|
39
|
+
extensions it sits on), because `drizzle-kit push` needs the same list. Use it, so the in-memory
|
|
40
|
+
database is exactly what a push would have made.
|
|
41
|
+
*/
|
|
42
|
+
const configPath = join(process.cwd(), 'drizzle.config.js');
|
|
43
|
+
if(existsSync(configPath)){
|
|
44
|
+
const { default: config } = await import(pathToFileURL(configPath).href);
|
|
45
|
+
for(const entry of [config?.schema].flat().filter(Boolean)){
|
|
46
|
+
const file = join(process.cwd(), entry);
|
|
47
|
+
if(existsSync(file)) Object.assign(schema, await import(pathToFileURL(realpathSync(file)).href));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
const client = new PGlite();
|
|
38
52
|
db = drizzlePglite(client, { schema });
|
|
39
53
|
|