let bcrypt = require('bcryptjs')
let randomColor = require('randomcolor')
var passportLocalSequelize = require('passport-local-sequelize');
let pagination = require('../lib/pagination.js')
const Errors = require('../lib/errors.js')
var crypto = require("crypto");
var cryptoRandomString = require("crypto-random-string");
module.exports = (sequelize, DataTypes) => {
    let TeamRoles = sequelize.define('TeamRoles', {
        name: {
            type: DataTypes.STRING,
            allowNull: false,
            validate: {
                isString(val) {
                    if (typeof val !== 'string') {
                        throw new sequelize.ValidationError('Team name must be a string')
                    }
                },
                len: {
                    args: [3, 20],
                    msg: 'Team name must be between 3 and 20 characters'
                }
            }
        },
        inviteUsers: {
            type: DataTypes.BOOLEAN,
            defaultValue: true
        },
        administrator: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        changeTeamMeta: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        changeTeamRoles: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        forumAdministrator: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        moderateForumThreads: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        changeTeamPrivacy: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        submitTeamItems: {
            type: DataTypes.BOOLEAN,
            defaultValue: false
        },
        priority: {
            type: DataTypes.BIGINT,
            default: 1,
            allowNull: false,
        },
        teamId: {
            type: DataTypes.BIGINT
        }
    })
    TeamRoles.associate = function (models) {
        TeamRoles.hasMany(models.Team)
    }


    return TeamRoles
}
