2

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.