Reputation: 1457
I am trying to drop all tables in a schema (Postgres 9.3). When the models were being created, I have specified which schema they belong to.
model.schema( "schema_name")
And I was able to generate all tables in this specific schema. No problem here. However, when I want to drop the tables in the same schema, I am having to explicitly set the search path for it to be successful.
db.sequelize.query("set search_path=consumer")
.then( function( arg ){
db.sequelize.drop({cascade:true})
.then( function( arg ){
fulfill( arg );
},function( err ){
reject( err );
});
});
When Sequelize claims support for PostgreSQL schema, I would expect that this detail must have been taken care of (because most of the other features work charmingly well!). So my question is : Do I have to set search path or am I missing some option that I am not making use of?
Upvotes: 2
Views: 2795
Reputation: 196
sequelize creates a clone of the object, sets the schema on it and returns the clone. Therefore the original object is unchanged.
Try
model.schema( "schema_name")
instead.
Upvotes: 2