There is not enough information to infer relation "__public__.collectionsTable.tokens"
.
Here's a simplified version of the schema.
In short, each collection can have multiple tokens, but each token can belong to only one collection.
I haven't had any issues with this schema for around the 6 months that we've been using it, but we wanted to try out drizzle studio and ran into that issue. The database is running on Planetscale, not sure if that's relevant.world
. Due to the reference to the world in the users_to_worlds I get the error:
Error: update or delete on table "worlds" violates foreign key constraint "users_to_worlds_world_id_worlds_id_fk" on table "users_to_worlds"
I believe what I want to use is a CASCADE delete where everything referencing a world is deleted when I delete a world. Is this possible through Drizzle? I can't seem to find anything on this.import { Pool } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import { PrismaClient } from "@prisma/client";
const globalForPrisma = global as unknown as { prisma: PrismaClient };
function makeClient() {
const neon = new Pool({ connectionString: process.env.DATABASE_URL });
const adapter = new PrismaNeon(neon);
return new PrismaClient({ adapter });
}
const db = globalForPrisma.prisma || makeClient();
if (process.env.NODE_ENV === "development") {
globalForPrisma.prisma = db;
}
export default db;