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

language "plpgsql" does not exist on Ubuntu Dev Container on Windows #465

Closed
ai opened this issue Dec 11, 2024 · 5 comments
Closed

language "plpgsql" does not exist on Ubuntu Dev Container on Windows #465

ai opened this issue Dec 11, 2024 · 5 comments

Comments

@ai
Copy link

ai commented Dec 11, 2024

Hi. I got strange error when I tried to run my server on different environment.

anguage "plpgsql" does not exist at 2024-12-09 11:40:52
        at he.Fe (file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-5L6BPGXX.js:1:17688)
        at he.rt (file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-5L6BPGXX.js:1:15073)
        at he.parse (file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-5L6BPGXX.js:1:13825)
        at I_.execProtocol (file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/index.js:3:2424729)
        at async I_.o (file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-Y4PL6ZOT.js:8:1846)
        at async file:///workspaces/slowreader/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-Y4PL6ZOT.js:8:2474

JS code:

import { PGlite } from '@electric-sql/pglite'
import { drizzle } from 'drizzle-orm/pglite'
import { migrate } from 'drizzle-orm/pglite/migrator'
import { join } from 'node:path'

import { config } from '../lib/config.ts'
import * as schema from './schema.ts'
export * from './schema.ts'

const MIGRATE_CONFIG = {
  migrationsFolder: join(import.meta.dirname, 'migrations')
}

export const db = drizzle(new PGlite('file://./db/pgdata'), { schema })
await migrate(db, MIGRATE_CONFIG)

The projects use Dev Container with Ubuntu image and works correctly on my laptop (with Fedora) but we are getting this issue on Windows machine.

We are also using pnpm if it is related.

@yacineb
Copy link
Contributor

yacineb commented Dec 11, 2024

Do you reproduce the issue with await db.exec("CREATE EXTENSION IF NOT EXISTS plpgsql;"); ran before migrate ? (the db here is your PGlite instance)

@ai
Copy link
Author

ai commented Dec 11, 2024

I don’t have such. But everything works on one machine without it.

Here is Drizzle migration files:

CREATE TABLE IF NOT EXISTS "sessions" (
	"createdAt" timestamp DEFAULT now() NOT NULL,
	"id" serial PRIMARY KEY NOT NULL,
	"token" text NOT NULL,
	"usedAt" timestamp DEFAULT now() NOT NULL,
	"userId" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
	"createdAt" timestamp DEFAULT now() NOT NULL,
	"id" text PRIMARY KEY NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "sessions" ADD CONSTRAINT "sessions_userId_users_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "sessionsUserIdx" ON "sessions" USING btree ("userId");

ALTER TABLE "users" ADD COLUMN "passwordHash" text;

ALTER TABLE "sessions" ADD COLUMN "clientId" text;

Do you know why I may need it on one machine and do not need on another?

@yacineb
Copy link
Contributor

yacineb commented Dec 12, 2024

@ai which node version are you using ? and which CPU architecture. Those can help investigating why you have such a difference

@ai
Copy link
Author

ai commented Dec 12, 2024

One machine (everything works):

  • Host OS: Linux (Fedora 41)
  • Dev Container OS: Ubuntu
  • Hardware: x86

Second machine, where it is not working:

  • Host OS: Windows
  • Dev Container OS: the same Ubuntu
  • Hardware: x86

photo_2024-12-12_12-09-32

@ai
Copy link
Author

ai commented Dec 12, 2024

I started to have language "plpgsql" does not exist error too on my machine. Very strange.

But seems like we can close it.

@ai ai closed this as completed Dec 12, 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

2 participants