From 2a695f24c6b4bf09256039e8fd562ca7a3eba5ea Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 3 Mar 2024 00:47:17 +0100 Subject: [PATCH] bugfix: def / init order --- database.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 };