Updated models and migrations to new spec
This commit is contained in:
28
models/band.js
Normal file
28
models/band.js
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
const {
|
||||
Model
|
||||
} = require('sequelize');
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class Band extends Model {
|
||||
/**
|
||||
* Helper method for defining associations.
|
||||
* This method is not a part of Sequelize lifecycle.
|
||||
* The `models/index` file will call this method automatically.
|
||||
*/
|
||||
static associate(models) {
|
||||
// define association here
|
||||
Band.hasMany(models.Character);
|
||||
}
|
||||
}
|
||||
Band.init({
|
||||
uniqueId: DataTypes.INTEGER,
|
||||
name: DataTypes.STRING,
|
||||
description: DataTypes.TEXT,
|
||||
imageURL: DataTypes.STRING,
|
||||
enabled: DataTypes.BOOLEAN
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Band',
|
||||
});
|
||||
return Band;
|
||||
};
|
||||
24
models/bot.js
Normal file
24
models/bot.js
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
const {
|
||||
Model
|
||||
} = require('sequelize');
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class Bot extends Model {
|
||||
/**
|
||||
* Helper method for defining associations.
|
||||
* This method is not a part of Sequelize lifecycle.
|
||||
* The `models/index` file will call this method automatically.
|
||||
*/
|
||||
static associate(models) {
|
||||
// define association here
|
||||
}
|
||||
}
|
||||
Bot.init({
|
||||
maintenance: DataTypes.BOOLEAN,
|
||||
adminIDs: DataTypes.STRING
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Guild',
|
||||
});
|
||||
return Bot;
|
||||
};
|
||||
@@ -10,22 +10,18 @@ module.exports = (sequelize, DataTypes) => {
|
||||
* The `models/index` file will call this method automatically.
|
||||
*/
|
||||
static associate(models) {
|
||||
Card.belongsTo(models.Character, {
|
||||
foreignKey: 'characterID',
|
||||
as: 'character'
|
||||
});
|
||||
Card.belongsTo(models.User, {
|
||||
foreignKey: 'ownerID',
|
||||
key: 'userId',
|
||||
as: 'owner'
|
||||
});
|
||||
Card.belongsTo(models.User);
|
||||
Card.belongsTo(models.Character);
|
||||
}
|
||||
}
|
||||
Card.init({
|
||||
ownerID: DataTypes.STRING,
|
||||
identifier: DataTypes.STRING,
|
||||
characterID: DataTypes.INTEGER,
|
||||
enabled: { type: DataTypes.BOOLEAN, defaultValue: true }
|
||||
characterId: DataTypes.INTEGER,
|
||||
quality: DataTypes.INTEGER,
|
||||
userId: DataTypes.STRING,
|
||||
imageHash: DataTypes.STRING,
|
||||
enabled: { type: DataTypes.BOOLEAN, defaultValue: true },
|
||||
printNr: DataTypes.INTEGER,
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Card',
|
||||
|
||||
@@ -10,18 +10,16 @@ module.exports = (sequelize, DataTypes) => {
|
||||
* The `models/index` file will call this method automatically.
|
||||
*/
|
||||
static associate(models) {
|
||||
Character.hasMany(models.Card, {
|
||||
foreignKey: 'characterID',
|
||||
as: 'cards'
|
||||
});
|
||||
Character.belongsToMany(models.Card, { through: 'CardCharacter' });
|
||||
Character.belongsTo(models.Band, { foreignKey: 'bandId', });
|
||||
}
|
||||
}
|
||||
Character.init({
|
||||
name: DataTypes.STRING,
|
||||
rarity: DataTypes.INTEGER,
|
||||
description: DataTypes.STRING,
|
||||
bandId: DataTypes.INTEGER,
|
||||
imageURL: DataTypes.STRING,
|
||||
imageHash: DataTypes.STRING
|
||||
description: DataTypes.TEXT,
|
||||
enabled: DataTypes.BOOLEAN
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Character',
|
||||
|
||||
@@ -14,9 +14,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
}
|
||||
}
|
||||
Guild.init({
|
||||
guildID: DataTypes.STRING,
|
||||
adminRoleID: DataTypes.STRING,
|
||||
owderID: DataTypes.STRING
|
||||
guildId: DataTypes.BIGINT,
|
||||
adminRoleId: DataTypes.BIGINT,
|
||||
active: DataTypes.INTEGER,
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Guild',
|
||||
|
||||
@@ -11,12 +11,13 @@ module.exports = (sequelize, DataTypes) => {
|
||||
*/
|
||||
static associate(models) {
|
||||
// define association here
|
||||
User.hasMany(models.Card);
|
||||
}
|
||||
}
|
||||
User.init({
|
||||
userID: DataTypes.STRING,
|
||||
banned: DataTypes.BOOLEAN,
|
||||
registredAt: DataTypes.DATE
|
||||
discordId: DataTypes.BIGINT,
|
||||
active: DataTypes.INTEGER,
|
||||
privacy: DataTypes.INTEGER
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'User',
|
||||
|
||||
Reference in New Issue
Block a user