Open rwest202 opened 5 years ago
Hmm I see, but does this cause any errors?
It doesn't add the columns to the new schema, since it thinks they already exist. I was able to resolve my issue by removing the schema-v1
. But it wasn't immediately obvious what was causing the issue.
Looks like there is a table_schema
key that you can check against, so something like
if (!tableColumns[type].some(row => row.column_name === field && row.table_schema === currentSchema)
https://github.com/fortunejs/fortune-postgres/blob/7d158ec79334584049fc2f8de404527eb24ae598/lib/index.js#L141-L142
Let's say I have a schema named
schema-v1
and another namedschema-v2
that both have a table calledusers
. Ifschema-v1
has a column in users like users.email then the below if statement will wrongly think that the column exists inschema-v2
. This is because information_schema.columns returns a list of columns in all schemas.https://github.com/fortunejs/fortune-postgres/blob/7d158ec79334584049fc2f8de404527eb24ae598/lib/index.js#L188
Solution should be to specify the exact schema to search in.