kaleembhatti
kaleembhatti
TTCTheo's Typesafe Cult
Created by kaleembhatti on 2/17/2024 in #questions
Drizzle + Turso Migration Problem
Npm Scripts:
"db:push": "drizzle-kit push:sqlite",
"db:generate": "drizzle-kit generate:sqlite",
"db:push": "drizzle-kit push:sqlite",
"db:generate": "drizzle-kit generate:sqlite",
Issue: When I run db:push, it tries to create the entire db instead of looking at the migration file Drizzle Config
import { type Config } from "drizzle-kit";

export default {
schema: "./src/server/db/schema.ts",
driver: "turso",
dbCredentials: {
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
},
out: "./drizzle",
tablesFilter: ["learningcambridgeforall_*"],
verbose: true,
strict: true,
} satisfies Config;
import { type Config } from "drizzle-kit";

export default {
schema: "./src/server/db/schema.ts",
driver: "turso",
dbCredentials: {
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
},
out: "./drizzle",
tablesFilter: ["learningcambridgeforall_*"],
verbose: true,
strict: true,
} satisfies Config;
Database Index ("/src/server/db/index.ts")
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

import { subjects } from "./schema";

const client = createClient({
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
});

export const db = drizzle(client, { schema: { ...subjects } });
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

import { subjects } from "./schema";

const client = createClient({
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
});

export const db = drizzle(client, { schema: { ...subjects } });
Database Schema ("src/server/db/schema.ts")
import { sql } from "drizzle-orm";
import { text, integer, sqliteTable, index } from "drizzle-orm/sqlite-core";

export const subjects = sqliteTable(
"subjects",
{
id: integer("id").notNull().primaryKey(),
title: text("title").notNull(),
overview: text("overview").notNull(),
visibility: text("visibility", {
enum: ["Pending", "Public", "Private"],
})
.notNull()
.default("Pending"),
educationLevel: text("education_level", {
enum: ["a_level", "o_level"],
}).notNull(),
createdAt: text("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
},
(table) => {
return {
titleIdx: index("title_idx").on(table.title),
};
},
);
import { sql } from "drizzle-orm";
import { text, integer, sqliteTable, index } from "drizzle-orm/sqlite-core";

export const subjects = sqliteTable(
"subjects",
{
id: integer("id").notNull().primaryKey(),
title: text("title").notNull(),
overview: text("overview").notNull(),
visibility: text("visibility", {
enum: ["Pending", "Public", "Private"],
})
.notNull()
.default("Pending"),
educationLevel: text("education_level", {
enum: ["a_level", "o_level"],
}).notNull(),
createdAt: text("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
},
(table) => {
return {
titleIdx: index("title_idx").on(table.title),
};
},
);
3 replies
TTCTheo's Typesafe Cult
Created by kaleembhatti on 2/11/2024 in #questions
Planetscale pricing changes (hobby plan not available)
No description
12 replies
TTCTheo's Typesafe Cult
Created by kaleembhatti on 1/11/2024 in #questions
Next js Form weird behavior
I am building a form where when i click on submit, the data does get updated but the ui starts to update every second, like an infinite loop I am using server actions with the new useFormState and useFormStatus
16 replies
TTCTheo's Typesafe Cult
Created by kaleembhatti on 1/8/2024 in #questions
Dynamic server error
i am new to react, nextjs and t3 stack in general i am trying to implement clerk with the t3 stack (app router, trpc, tailwind, prisma) but i am getting dynamic server error when pushing my code to vercel can someone please guide me
43 replies