diff --git a/database.js b/database.js index 7c43f0b..fefc21d 100644 --- a/database.js +++ b/database.js @@ -16,14 +16,6 @@ const sequelize = new Sequelize({ logging: false }); -const Guild = defineGuild(sequelize); -Guild.hasMany(VoiceChannel, { foreignKey: 'guild', onDelete: 'CASCADE' }); -Guild.hasMany(Message, { foreignKey: 'guild', onDelete: 'CASCADE' }); -Guild.hasMany(Role, { foreignKey: 'guild', onDelete: 'CASCADE' }); - -const Role = defineRole(sequelize); -Role.hasMany(RoleEmojiPair, { foreignKey: 'role', onDelete: 'CASCADE' }); - const RoleEmojiPair = defineRoleEmojiPair(sequelize); const VoiceChannel = defineVoiceChannel(sequelize); @@ -31,5 +23,13 @@ const VoiceChannel = defineVoiceChannel(sequelize); const Message = defineMessage(sequelize); Message.hasMany(RoleEmojiPair, { foreignKey: 'message', onDelete: 'CASCADE' }); +const Role = defineRole(sequelize); +Role.hasMany(RoleEmojiPair, { foreignKey: 'role', onDelete: 'CASCADE' }); + +const Guild = defineGuild(sequelize); +Guild.hasMany(VoiceChannel, { foreignKey: 'guild', onDelete: 'CASCADE' }); +Guild.hasMany(Message, { foreignKey: 'guild', onDelete: 'CASCADE' }); +Guild.hasMany(Role, { foreignKey: 'guild', onDelete: 'CASCADE' }); + sequelize.sync(); export { sequelize, Guild, Role, RoleEmojiPair, VoiceChannel, Message };