Skip to content

Commit 42ec90a

Browse files
committed
fix (app): prevent excess sync() calls during db seed
Previously, .sync() was being called once in server/config/seed.js and once during sqldb.sequelize.sync() in server/app.js. As a result, duplicate queries were being sent to the database if the tables needed to be defined causing an error when it tries to define constraints a second time (like for an identity column). Seed.js is wrapped in a function and contains the conditional to determine whether to seed the database. This makes it easy to include in the promise chain under sqldb.sequelize.sync().
1 parent afc6df1 commit 42ec90a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: templates/app/server/app.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sqldb.sequelize.sync()
4444
console.log('Server failed to start due to error: %s', err);
4545
});
4646
<% } else { %>
47+
seedDatabaseIfNeeded();
4748
setImmediate(startServer);
4849
<% } %>
4950
// Expose app

0 commit comments

Comments
 (0)