migrate
migrate copied to clipboard
Redshift: Add support for `x-migrations-table-quoted`
Is your feature request related to a problem? Please describe.
My company has a Redshift DB that is shared by a small number of services. I'd like to add support for migrations for my service (and still allow other services to each have their own separate schema_migrations). Unfortunately, the public schema is not available... and the Redshift connection does not currently allow one to specify another schema to use for the schema_migrations table.
In both of the following situations:
golang-migrateis used apply migrations to the Redshift DBmigrateCLI is used to perform any action (includingversion)
... Redshift tries to create tables in the public schema REGARDLESS of how the Redshift connection is configured.
e.g.
migrate -path /blah -database "redshift://${USER}:${PASS}@${HOST}:${PORT}/${DB}?x-migrations-table=example.schema_migrations" version- This attempts to create the table
public."example.schema_migrations"which is:- Not the intent
- Still uses the
publicschema, which is forbidden by policy. does... so I'm unable to specify a schema other thanpublic.
- This attempts to create the table
migrate -path /blah -database "redshift://${USER}:${PASS}@${HOST}:${PORT}/${DB}?x-migrations-table=\"example\".\"schema_migrations\"" version- This returns the error
error: pq: zero-length delimited identifier at or near """" in line 0: CREATE TABLE ""example"."schema_migrations"" (version bigint not null primary key, dirty boolean not null) - The Redshift connector doesn't support the
x-migrations-table-quotedquery param, like PostgreSQL connector does.
- This returns the error
Describe the solution you'd like
Redshift connections would support x-migrations-table-quoted (like PostgreSQL) so that the target schema & table name can both be specified.
Describe alternatives you've considered
- Moving to a different migration library
- Writing my own migration utility, from scratch
- Creating a fork of
golang-migrate/migrateand modifying the Redshift code
Additional context
The public schema in my company's Redshift DB is locked down for reasons I cannot get into... so I can't rely on simply using a different table name in the public schema, for each service. e.g. the following won't work for us:
public/
|
+ service1_schema_migrations
|
+ service2_schema_migrations