Upgrade sequelize and remove unique email constraints

This commit is contained in:
Jori Lallo
2017-07-12 00:28:18 -07:00
parent 3b146d9b47
commit cd584da5cf
10 changed files with 452 additions and 400 deletions

View File

@@ -14,25 +14,6 @@ const Team = sequelize.define(
slackData: DataTypes.JSONB,
},
{
classMethods: {
associate: models => {
Team.hasMany(models.Collection, { as: 'atlases' });
Team.hasMany(models.Document, { as: 'documents' });
Team.hasMany(models.User, { as: 'users' });
},
},
instanceMethods: {
async createFirstCollection(userId) {
const atlas = await Collection.create({
name: this.name,
description: 'Your first Collection',
type: 'atlas',
teamId: this.id,
creatorId: userId,
});
return atlas;
},
},
indexes: [
{
unique: true,
@@ -42,4 +23,21 @@ const Team = sequelize.define(
}
);
Team.associate = models => {
Team.hasMany(models.Collection, { as: 'atlases' });
Team.hasMany(models.Document, { as: 'documents' });
Team.hasMany(models.User, { as: 'users' });
};
Team.prototype.createFirstCollection = async function(userId) {
const atlas = await Collection.create({
name: this.name,
description: 'Your first Collection',
type: 'atlas',
teamId: this.id,
creatorId: userId,
});
return atlas;
};
export default Team;