Sequelize.sync() method
Creates every table, then every view, then every column index.
Signature:
sync(options?: SyncOptions): Promise<any>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
options |
(Optional) Sequelize's own sync options, plus |
Returns:
Promise<any>
The connection, once every pass has finished.
Remarks
Sequelize's own sync knows about tables only. This one runs it first, then replaces the views declared with View or DynamicView, then creates the indices declared with ColumnIndex or NullableIndex. Views come before indices so an index declared on a materialized view has something to attach to, and both come after the tables a view selects from.
The three passes used to overlap. The index pass was started but never waited for and its result was discarded, so this resolved while indices were still being created, and a failure in that pass became an unhandled rejection — fatal on any current Node — instead of rejecting here. The options were not forwarded to the view pass either, which left withoutDrop doing nothing. All three are fixed.