chore: upgrade sequelize (#965)

* 0.18.0

* chore: Upgrade sequelize 4 -> 5

* fix: migrations v5 support

* fix: Majority of test failures

* fix: the rest of v5 tests
This commit is contained in:
Tom Moor
2019-06-23 15:49:45 -07:00
committed by GitHub
parent 595adeb55f
commit 32f83311f6
35 changed files with 260 additions and 7662 deletions

View File

@@ -156,7 +156,6 @@ Document.associate = models => {
],
where: {
publishedAt: {
// $FlowFixMe
[Op.ne]: null,
},
},
@@ -182,7 +181,7 @@ Document.associate = models => {
}));
};
Document.findById = async (id, options) => {
Document.findByPk = async (id, options) => {
const scope = Document.scope('withUnpublished');
if (isUUID(id)) {
@@ -300,7 +299,7 @@ Document.searchForUser = async (
Document.addHook('beforeSave', async model => {
if (!model.publishedAt) return;
const collection = await Collection.findById(model.collectionId);
const collection = await Collection.findByPk(model.collectionId);
if (!collection || collection.type !== 'atlas') return;
await collection.updateDocument(model);
@@ -310,7 +309,7 @@ Document.addHook('beforeSave', async model => {
Document.addHook('afterCreate', async model => {
if (!model.publishedAt) return;
const collection = await Collection.findById(model.collectionId);
const collection = await Collection.findByPk(model.collectionId);
if (!collection || collection.type !== 'atlas') return;
await collection.addDocumentToStructure(model);
@@ -366,7 +365,7 @@ Document.prototype.archiveWithChildren = async function(userId, options) {
Document.prototype.publish = async function() {
if (this.publishedAt) return this.save();
const collection = await Collection.findById(this.collectionId);
const collection = await Collection.findByPk(this.collectionId);
if (collection.type !== 'atlas') return this.save();
await collection.addDocumentToStructure(this);
@@ -402,7 +401,6 @@ Document.prototype.unarchive = async function(userId) {
where: {
id: this.parentDocumentId,
archivedAt: {
// $FlowFixMe
[Op.eq]: null,
},
},

View File

@@ -131,7 +131,6 @@ Team.prototype.removeAdmin = async function(user: User) {
teamId: this.id,
isAdmin: true,
id: {
// $FlowFixMe
[Op.ne]: user.id,
},
},

View File

@@ -159,7 +159,7 @@ User.beforeDestroy(removeIdentifyingInfo);
User.beforeSave(uploadAvatar);
User.beforeCreate(setRandomJwtSecret);
User.afterCreate(async user => {
const team = await Team.findById(user.teamId);
const team = await Team.findByPk(user.teamId);
sendEmail('welcome', user.email, { teamUrl: team.url });
});