module.exports = (sequelize, DataTypes) => {
	let Settings = sequelize.define('Settings', {
		siteName: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The name must be a string')
					}
				}
			}
		},
		siteDesc: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The description must be a string')
					}
				}
			}
		},
		bannerText: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The banner text must be a string')
					}
				}
			}
		},
		bannerEnabled: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
		maintenance: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
		gateway: {
			type: DataTypes.STRING,
			defaultValue: "wss://gateway.kaverti.com"
		},
		logo: {
			type: DataTypes.STRING,
			defaultValue: "https://cdn.kaverti.com/logo.png"
		},
		icon: {
			type: DataTypes.STRING,
			defaultValue: "/favicon.png"
		},
		RegistrationsDisabled: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
		latestAPIVersion: {
			type: DataTypes.TEXT,
			defaultValue: "0.154"
		},
		latestStableVersion: {
			type: DataTypes.TEXT,
			defaultValue: "0.154-stable"
		},
		latestCanaryVersion: {
			type: DataTypes.TEXT,
			defaultValue: "0.154-canary"
		},
	}, {
		classMethods: {
			set (values) {
				return Settings.upsert(values)
			},
			get () {
				return Settings.findByPk(1)
			}
		}
	})

	return Settings
}
