Woet
Woet
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
makes sense, thanks!
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
first time building some with the t3-stack, was expecting it to already take care of the need to import "dotenv/config";
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
thanks @barry ! that idd did the trick
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
They get picked up at runtime, but just not in this script
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
But for some reason they're not picked up when running the scripts
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
Hmm all these variables are defined in my .env file though
11 replies
TTCTheo's Typesafe Cult
Created by Woet on 4/21/2024 in #questions
Run migration with Drizzle for Neon
This is my migration file:
import { env } from "~/env";
import { drizzle } from "drizzle-orm/neon-http";
import { migrate } from "drizzle-orm/neon-http/migrator";
import { neon } from "@neondatabase/serverless";

const sql: ReturnType<typeof neon> | undefined = neon(env.DATABASE_URL);

const db = drizzle(sql);

const main = async () => {
try {
console.log("DATABASE URL");
console.log(env.DATABASE_URL);
await migrate(db, {
migrationsFolder: "src/db/global/migrations",
});

console.log("Migration complete!");
} catch (error) {
console.error("Migration failed", error);
}
};

await main();
import { env } from "~/env";
import { drizzle } from "drizzle-orm/neon-http";
import { migrate } from "drizzle-orm/neon-http/migrator";
import { neon } from "@neondatabase/serverless";

const sql: ReturnType<typeof neon> | undefined = neon(env.DATABASE_URL);

const db = drizzle(sql);

const main = async () => {
try {
console.log("DATABASE URL");
console.log(env.DATABASE_URL);
await migrate(db, {
migrationsFolder: "src/db/global/migrations",
});

console.log("Migration complete!");
} catch (error) {
console.error("Migration failed", error);
}
};

await main();
11 replies