Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I connect to a specific schema in a postgres database? #118

Closed
lroal opened this issue Nov 21, 2024 Discussed in #117 · 0 comments
Closed

How do I connect to a specific schema in a postgres database? #118

lroal opened this issue Nov 21, 2024 Discussed in #117 · 0 comments

Comments

@lroal
Copy link
Member

lroal commented Nov 21, 2024

Discussed in #117

Originally posted by yayza November 20, 2024

import orange from 'orange-orm';
import { env } from '$env/dynamic/private';

const map = orange.map((x) => ({
	tag: x.table('tag').map(({ column }) => ({
		id: column('id').numeric().primary().notNullExceptInsert(),
		name: column('name').string(),
		createdAt: column('createdAt').dateWithTimeZone().default('now()'),
		updatedAt: column('updatedAt').dateWithTimeZone().default('now()').notNullExceptInsert()
	}))
}));

export const db = map.postgres(env.DATABASE_URL + '?search_path=custom');
error: relation "tag" does not exist
    at Parser.parseErrorMessage (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:283:98)
    at Parser.handlePacket (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:122:29)
    at Parser.parse (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:35:38)
    at Socket.<anonymous> (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:551:15)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23) {
  length: 103,
  severity: 'ERROR',
  code: '42P01',
  detail: undefined,
  hint: undefined,
  position: '129',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_relation.c',
  line: '1449',
  routine: 'parserOpenTable'
}

If I create the table in public schema it works.

Thanks!

@lroal lroal closed this as completed in 1479717 Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant