-
Notifications
You must be signed in to change notification settings - Fork 642
Description
Problem
I have a query that uses the JoinEagerAlgorithm, which uses the db metadata cache to explicitly enumerate the columns of both tables. However, I want to drop a column from the db. When I drop the db column, the next time that query runs I get a "column does not exist" error from postgres.
Restarting the application refreshes the cache, but there isn't really a way to avoid some timing gap between the migration and the restart.
Solution
@koskimas suggested in the Gitter channel that we could expose the Model.fetchDbMetadata() method and allow people to override it. This would allow me to implement something like:
class Person extends Model {
static fetchDbMetadata() {
return Object.keys(this.jsonSchema.properties);
}
}
Then, I can deploy a version of my application where that column has been removed from the JSON Schema, before running the migration. Because the application will never use that column, it can be safely dropped while the application is running.