#[SOLVED] custom schema not possible with supabase?

1 messages · Page 1 of 1 (latest)

crystal gyro
#

I'm trying to write to a custom schema:

const supabase = new Supabase<Database, "custom_schema">({
id: "supabase",
supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
});

but when I use:

await io.supabase.client.from('test_table').update({test: 'updated'}).eq('id', id)

the error says "there is no table "public.test_table

prisma jungle
#

You haven't specified your custom_schema properly. The bit in the angle brackets is just for TypeScript types, it has no impact on runtime code.

You need to do this I think:

const supabase = new Supabase<Database, "custom_schema">({
  id: "supabase",
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
  {
     db: {
      schema: "custom_schema"
    } 
  }
});
crystal gyro
#

gettting an error with that:

Import trace for requested module:
./jobs/rb2b/newsignup.ts
./jobs/index.ts
./app/api/trigger/route.ts
 ✓ Compiled /not-found in 951ms (282 modules)
 ⨯ ./jobs/rb2b/newsignup.ts
Error: 
  × Unexpected token `{`. Expected identifier, string literal, numeric literal or [ for the computed key
    ╭─[/home/kyle/teller/teller-app/jobs/rb2b/newsignup.ts:16:1]
 16 │   id: "supabase",
 17 │   supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
 18 │   supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
 19 │   {
    ·   ─
 20 │      db: {
 21 │       schema: "retention"
 22 │     } 
    ╰────
#

trying this format:

const supabase = new Supabase<Database, "retention">({
  id: "supabase",
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
  db: {
    schema: "retention"
  }
})

I get:

Object literal may only specify known properties, and 'db' does not exist in type 'SupabaseIntegrationOptions<"retention">'.ts(2353)
prisma jungle
#

Ah whoops I missed the fact it was in an object already

#
const supabase = new Supabase<Database, "retention">({
  id: "supabase",
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
  options: {
     db: {
      schema: "retention"
    } 
  }
});
crystal gyro
#

I'll try this!

#

that did it! 🫶

prisma jungle
#

Great 👍