Q:

How to change what sequence will be used by postgresql when it gets next value for id?

I have 2 table with field id which automatic created by sequelize.
table1
id integer not null default nextval('table1_d_seq'::regclass)

table2
id integer not null default nextval('table2_d_seq'::regclass)

Could I tune sequelize to create id field in table2 with modifier nextval('table1_d_seq'::regclass) ?

A:

You can create a migration file which will change specified column and set it's default value via the sequelize.query() method available through queryInterface
module.exports = {
    up: function (queryInterface, Sequelize){

        return queryInterface.sequelize.query(
            "ALTER TABLE table2 ALTER COLUMN id SET DEFAULT nextval('table1_d_seq'::regclass)"
        );

    },

    down: function (queryInterface, Sequelize) {

    }
}

