ijohnston
ijohnston
DTDrizzle Team
Created by ijohnston on 12/4/2024 in #help
_snapshot.json data is malformed
Whenever I run npx drizzle-kit pull to get my pre-existing Supabase schema it works. If I then try to run npx drizzle-kit generate it says supabase/migrations/meta/20241203225947_snapshot.json data is malformed I don't know what is causing the issue. I did not edit the 20241203225947_snapshot.json
2 replies
DTDrizzle Team
Created by ijohnston on 11/21/2024 in #help
Supabase [users.id]
I ran drizzle-kit pull to get my existing schema from Supabase. The schema output included the following
export const notifications = pgTable("notifications", {
id: uuid().defaultRandom().primaryKey().notNull(),
userId: uuid("user_id").notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
body: text().notNull(),
}, (table) => {
return {
notificationsUserIdFkey: foreignKey({
columns: [table.userId],
foreignColumns: [users.id],
name: "notifications_user_id_fkey"
}),
}
});
export const notifications = pgTable("notifications", {
id: uuid().defaultRandom().primaryKey().notNull(),
userId: uuid("user_id").notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
body: text().notNull(),
}, (table) => {
return {
notificationsUserIdFkey: foreignKey({
columns: [table.userId],
foreignColumns: [users.id],
name: "notifications_user_id_fkey"
}),
}
});
The issue was with [users.id]. It said: Cannot find name 'users'.ts(2304). I updated [users.id] to be [authUsers.id]. I also imported:
import {
authenticatedRole,
authUid,
authUsers,
realtimeMessages,
realtimeTopic,
supabaseAuthAdminRole,
} from "drizzle-orm/supabase";
import {
authenticatedRole,
authUid,
authUsers,
realtimeMessages,
realtimeTopic,
supabaseAuthAdminRole,
} from "drizzle-orm/supabase";
Is that correct fix? The error went away, but this is all new to me.
5 replies