Kuba
Kuba
Explore posts from servers
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
If you ever do - please, let us know - you might help someone who will have similar setup. Good luck!
22 replies
DTDrizzle Team
Created by dondycles on 10/5/2024 in #help
React Vite env problem
Use process.env instead and don't forget to load env vars:
import { defineConfig } from "drizzle-kit";
import { config } from "dotenv";
import { expand } from "dotenv-expand";

const env = config();
expand(env);

export default defineConfig({
schema: "./src/core/database/schema.ts",
out: "./database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
verbose: true,
strict: true,
});
import { defineConfig } from "drizzle-kit";
import { config } from "dotenv";
import { expand } from "dotenv-expand";

const env = config();
expand(env);

export default defineConfig({
schema: "./src/core/database/schema.ts",
out: "./database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
verbose: true,
strict: true,
});
5 replies
DTDrizzle Team
Created by dondycles on 10/5/2024 in #help
React Vite env problem
But from quickly looking at it - import.meta.env is available only when running through vite - which doesn't happen when running drizzle-kit
5 replies
DTDrizzle Team
Created by dondycles on 10/5/2024 in #help
React Vite env problem
Take a look at https://discord.com/channels/1043890932593987624/1290460784912240721 I've gone through the similar debugging process there + given extra tip to consider in such setup
5 replies
DTDrizzle Team
Created by François on 10/3/2024 in #help
Anyone also experiencing this issue?
That's actually good spot! I was thinking lately about integrating prepared statements myself, but if it results in performance drop, then I might subscribe to these issues for a bit
8 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Also, since you're using multi-stage build - you might want to use slimmer base image instead of just node
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
docker-compose has depends or something similar, so you could utilize that
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Or, another idea - you can create a one-shot container, that would contain just drizzle-kit, run the migrations from it
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Ah, I think I misunderstood. Instead of copying full node_modules, you can install these two packages on the stages you need them, I can't really think about any other solution
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Move it from dev-dep to normal deps then
22 replies
DTDrizzle Team
Created by Mozzy on 10/3/2024 in #help
`Error: no such column: unboxes.rarity` with `findMany()`
You're using query - did you defined and exported relations for your tables?
32 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Besides that, MJS is just a regular JS file - and since it is, you can run it without compilation step that ts files require
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
the .mjs is just a convention to tell that a given JS file uses ESM-import syntax, instead of node's require
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
With mjs, it's just a regular js file that utilizes ESM modules, so you can use import { ... } from "..." as usual
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
With tsx - you install tsx and just run tsx migrate.ts, as simple as that
22 replies
DTDrizzle Team
Created by François on 10/3/2024 in #help
Anyone also experiencing this issue?
I haven't used prepared statements myself, but I would guess that creating a statement and executing it are two different things, and the former might take longer, thus your execution takes circa 40ms
8 replies
DTDrizzle Team
Created by François on 10/3/2024 in #help
Anyone also experiencing this issue?
Since you're using prepared statements, shoudn't you start console.time just before
const existsResult = await existsPrepared.execute({id})
const existsResult = await existsPrepared.execute({id})
?
8 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
Also it seems that in your case drizzle-kit: not found it is not installed - I would look into whether npm ci installs dev-dependencies or not. I'm assuming that you have drizzle-kit as a dev-dep
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
You cannot run ts files without compiling them first, technically. But there are many tools that allow you to do it with a bit of magic in the background. My favourite is to use tsx for that. I personally setup my programmatic migrations with mjs to avoid this exact compilation problem
22 replies