drizzle-kit generate doesn't run custom sql

In addition to my schema.ts file to define tables, I also have functions_and_triggers.ts to create functions and triggers for Supabase
export const customAccessTokenHook = async () => {
await db.execute(sql`
CREATE OR REPLACE FUNCTION public.custom_access_token_hook(event jsonb)
RETURNS jsonb
LANGUAGE plpgsql
AS $$
BEGIN
// do stuff here
END;
$$;
`);
};
export const customAccessTokenHook = async () => {
await db.execute(sql`
CREATE OR REPLACE FUNCTION public.custom_access_token_hook(event jsonb)
RETURNS jsonb
LANGUAGE plpgsql
AS $$
BEGIN
// do stuff here
END;
$$;
`);
};
However when I run drizzle-kit generate it only runs the table creation and not the other file Here's my drizzle.config.ts
export default defineConfig({
dialect: 'postgresql',
schemaFilter: ['public'],
schema: './src/lib/db/schema/*',
out: './supabase/migrations',
dbCredentials: {
url: process.env.DATABASE_URL || 'postgresql://postgres:[email protected]:54322/postgres'
}
});
export default defineConfig({
dialect: 'postgresql',
schemaFilter: ['public'],
schema: './src/lib/db/schema/*',
out: './supabase/migrations',
dbCredentials: {
url: process.env.DATABASE_URL || 'postgresql://postgres:[email protected]:54322/postgres'
}
});
2 Replies
DoggeSlapper
DoggeSlapper4mo ago
AFAIK you need to define your migrations manually if u want stuff that is not generated by drizzle drizzle-kit generate custom will create an empty file you need to put your triggers/ function and custom stuff there
Minh Techie
Minh TechieOP4mo ago
thanks it works now
Want results from more Discord servers?
Add your server