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

[FEATURE]: skip schema check in migrator #3584

Open
1 task done
a-ursino opened this issue Nov 20, 2024 · 0 comments
Open
1 task done

[FEATURE]: skip schema check in migrator #3584

a-ursino opened this issue Nov 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@a-ursino
Copy link

a-ursino commented Nov 20, 2024

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Feature:
Provide a way to bypass the check CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}
when the default "public" schema is used in Postgres with

  await migrate(db, {
    migrationsSchema: 'public',
    migrationsFolder,
  });

Reason:
It is possible that in high regulated environments the user executing the migration doesn't have the permissions for any operation on the schema, even checking if it exists (this is the reason why we use "public" in the first place).
The above statement will trigger an error "permission denied" and abort the entire migration.

It should be quite easy just changing

await session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);

with

if(migrationsSchema !=='public') {
	await session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);
}

The public schema should exists by default in Postgres https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PUBLIC

I can create a PR for it if you're happy with the approach.

@a-ursino a-ursino added the enhancement New feature or request label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant