_Zaizen_
Explore posts from serversDTDrizzle Team
•Created by _Zaizen_ on 6/4/2024 in #help
PGLite indexedDB migration error
hey everyone I'm trying to use PGlite with indexed db as a storage.
It seems like the migrate function has an error though:
Here's a snippet from my react app:
import * as schema from "./drizzle/schema.js";
.....
useEffect(() => {
const initDb = async () => {
const bufferDb = new PGlite("idb://test");
await bufferDb.waitReady;
const bufferDrizzle = drizzle(bufferDb, { schema });
const migrationPath = "./src/drizzle/migrations";
await migrate(bufferDrizzle, { migrationsFolder: migrationPath });
setDb(bufferDrizzle);
};
initDb();
}, []);
In the browser debug console:
Uncaught (in promise) TypeError: import_node_fs.default.existsSync is not a function
readMigrationFiles migrator.ts:40
migrate migrator.ts:9
initDb App.jsx:20
App2 App.jsx:24
React 8
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
__require chunk-LNEMQRCO.js:9
js index.js:6
__require chunk-LNEMQRCO.js:9
React 2
__require chunk-LNEMQRCO.js:9
js React
__require chunk-LNEMQRCO.js:9
js React
__require chunk-LNEMQRCO.js:9
<anonymous> react-dom_client.js:38
Is the migrate non compatible with pglite?
Thanks1 replies
DTDrizzle Team
•Created by _Zaizen_ on 3/28/2024 in #help
Issue with CURRENT_TIMESTAMP bun:sqlite
I have the following table:
export const token = sqliteTable("token", {
token: text("token").notNull().primaryKey(),
usage_started: integer("usage_started", { mode: "boolean" })
.notNull()
.default(false),
usage_started_timestamp: integer("usage_started_timestamp", {
mode: "timestamp_ms",
}),
used: integer("used", { mode: "boolean" }).notNull().default(false),
used_timestamp: integer("used_timestamp", { mode: "timestamp_ms" }),
expiration_timestamp: integer("expiration_timestamp", {
mode: "timestamp_ms",
})
.notNull()
.default(-1),
instance_id: integer("instance_id")
.notNull()
.references(() => instance.id),
});
When running
await db.insert(token).values({
token: tokenId,
instance_id: instanceId,
expiration_timestamp: currentTimestamp + 86400000,
});
2 replies