You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sequelize#sync({ force: true, schema }) drops tables in the default schema #18423
Sequelize#sync calls this.drop({ ...options }) (sequelize.js:487) before syncing each model. Sequelize#drop (:557) calls model.drop(options) → queryInterface.dropTable(model), which uses the model's own table and ignores options.schema.
With two models and sequelize.sync({ force: true, schema: 'tenant' }) on postgres:
DROP TABLE IF EXISTS "Us" CASCADE <- default schema
DROP TABLE IF EXISTS "Ts" CASCADE
...
DROP TABLE IF EXISTS "tenant"."Us" CASCADE <- correct, from Model.sync
CREATE TABLE IF NOT EXISTS "tenant"."Us" (...)
schema is documented SyncOptions API (sequelize.d.ts:64), so this destroys default-schema tables during what should be a tenant-scoped sync.
#18406 fixes the equivalent bug in Model.sync but not this one. The fix needs care: the bulk drop exists for foreign-key topological ordering, so it can't simply be skipped when schema is set.
I'll work on a fix for this — sequelize.sync({ force: true, schema }) still drops default-schema tables via the bulk drop path that #18406 didn't cover. Opening a PR shortly.
Activity
Yahiro025 commentedon Sep 22, 2026
I'll work on a fix for this — sequelize.sync({ force: true, schema }) still drops default-schema tables via the bulk drop path that #18406 didn't cover. Opening a PR shortly.