postgres-migrations
postgres-migrations copied to clipboard
Implementing on a new db
I am attempting to use this library to bootstrap a developer environment with GitPod. However, when I run the one script that sets up the entire db, I am getting this error:
Migrations error Error: Migration failed. Reason: An error occurred running 'rolledUp'. Rolled back this migration. No further migrations were run. Reason: relation "migrations" does not exist at /workspace/XXX/node_modules/postgres-migrations/dist/migrate.js:63:27 at processTicksAndRejections (internal/process/task_queues.js:93:5) at async /workspace/XXX/node_modules/postgres-migrations/dist/with-lock.js:25:28 at async /workspace/XXX/node_modules/postgres-migrations/dist/with-connection.js:16:28 at async /workspace/XXX/src/migrate.js:52:9 { cause: Error: An error occurred running 'rolledUp'. Rolled back this migration. No further migrations were run. Reason: relation "migrations" does not exist at /workspace/XXX/node_modules/postgres-migrations/dist/run-migration.js:36:15 at processTicksAndRejections (internal/process/task_queues.js:93:5) at async /workspace/XXX/node_modules/postgres-migrations/dist/migrate.js:54:32 at async /workspace/XXX/node_modules/postgres-migrations/dist/with-lock.js:25:28 at async /workspace/XXX/node_modules/postgres-migrations/dist/with-connection.js:16:28 at async /workspace/XXX/src/migrate.js:52:9 }
This is the code block where the error is originating:
const { createDb, migrate } = require("postgres-migrations");
const database = 'XX';
const cn = {
database,
user: "XXXX",
password: "XXXXX",
host: "localhost",
port: 5432,
};
const dbConfig = { database, ...cn };
try {
await createDb(database, {
...dbConfig,
})
await migrate(dbConfig, "src/sql-migrations/").then(a => console.log("migrations applide", a)) // Line 52
}
catch (e) { console.error("Migrations error", e) }
What can you tell me about your database setup?
Is it related to #33?
It's a brand new, clean db. I doubt it's related to #33 , but it is possible. I am using a custom db name though
Is it configured in any way, or is it 'out of the box' Postgres, for example from Dockerhub?
What Postgres version is it?
I assume you're using the latest version of this library?
Custom database name should be fine. There are plenty of tests for that.
It's a Dockerfile based on the latest version of gitpod/workspace-postgres
Are you able to provide a reproduction? I'm not sure there's much I can do otherwise.
I tried running the tests against gitpod/workspace-postgres
but it looks like there's no port 5432 exposed.
I am running across a similar issue.. I believe it would occur if the migrations folder is outside of the users current schema search path in postgres ..
in my case migrations is in the auth schema.. but if I check the users default search_path for the user connecting to the postgres instance .. it shows $user, public .. so it doesn't find the migrations table..
applying a simple
ALTER USER postgres SET search_path TO "$user", public, auth
solved the issue
Even after ALTER USER postgres SET search_path TO "$user", public, auth
I get the same error
How do I revert the ALTER USER ..
statement?
I'm trying to use it with Supabase
@CanRau Same. Any solution?
Am using currently https://github.com/urbica/pg-migrate
@CanRau Thanks
Check your migration file ("rolledUp"). If it contains something like this:
SELECT pg_catalog.set_config('search_path', '', false);
try removing this line