Migrate atlasId -> collectionId

This commit is contained in:
Tom Moor
2018-08-07 23:23:26 -07:00
parent f49c495a9a
commit 18cfe26e83
11 changed files with 50 additions and 24 deletions

View File

@ -53,7 +53,7 @@ const Collection = sequelize.define(
// Create intro document if first collection for team
const document = await Document.create({
parentDocumentId: null,
atlasId: collection.id,
collectionId: collection.id,
teamId: collection.teamId,
userId: collection.creatorId,
lastModifiedById: collection.creatorId,
@ -78,7 +78,7 @@ const Collection = sequelize.define(
Collection.associate = models => {
Collection.hasMany(models.Document, {
as: 'documents',
foreignKey: 'atlasId',
foreignKey: 'collectionId',
onDelete: 'cascade',
});
Collection.belongsTo(models.Team, {
@ -99,7 +99,7 @@ Collection.associate = models => {
Collection.addHook('afterDestroy', async model => {
await Document.destroy({
where: {
atlasId: model.id,
collectionId: model.id,
},
});
});