Sequelize migrations ignores search_path
Basically that's not a bug but more of a feature request.
What you are doing?
I'm trying to run my migration.
export const up = (queryInterface: Sequelize.QueryInterface) => {
return queryInterface.renameColumn("my_table_name", "col_name_old", "col_name_new");
};
export const down = (queryInterface: Sequelize.QueryInterface) => {
return queryInterface.renameColumn("my_table_name", "col_name_new", "col_name_old");
};
What do you expect to happen?
I expected the column to rename.
What is actually happening?
I got an error:
[31mERROR:[39m No description found for "my_table_name" table. Check the table name and schema; remember, they _are_ case sensitive.
Dialect: postgres Database version: 11.1 Sequelize CLI version: 5.3.0 Sequelize version: 4.38.0
As I understand, when sequelize migration gets a command to renameColumn, it first tries to get some metadata about this table, something like this:
SELECT *
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'my_table_name'
The problem here is that it expects the table to be in schema public. I have my table in a custom schema (let's say my_custom_schema), but this schema is added into postgre's search_path. What do you guys think about iterating over schemas from search_path list instead of using public when selecting metadata?
P.S. I know that I can specify schema explicitly like this:
return queryInterface.renameColumn({
schema: "my_custom_schema",
tableName: "my_table_name"
}, "col_name_old", "col_name_new");
In this issue I wanted to discuss the behaviour when schema is not defined explicitly.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.