2024-02-06 15:18:06 +00:00
|
|
|
import defineRoleEmojiPair from './models/roleEmojiPairs.js';
|
|
|
|
import defineVoiceChannel from './models/voiceChannels.js';
|
|
|
|
import defineMessage from './models/messages.js';
|
|
|
|
import { Sequelize } from 'sequelize';
|
|
|
|
import { config } from 'dotenv';
|
|
|
|
config();
|
|
|
|
|
|
|
|
const { DB_NAME } = process.env;
|
2024-02-11 01:04:12 +00:00
|
|
|
/** The database instance used as an ORM in this project. */
|
2024-02-06 15:18:06 +00:00
|
|
|
const sequelize = new Sequelize({
|
|
|
|
storage: `${DB_NAME}.sqlite`,
|
|
|
|
dialect: 'sqlite',
|
|
|
|
logging: false
|
|
|
|
});
|
2024-02-07 20:02:37 +00:00
|
|
|
|
2024-02-06 15:18:06 +00:00
|
|
|
const RoleEmojiPair = defineRoleEmojiPair(sequelize);
|
2024-02-07 20:02:37 +00:00
|
|
|
|
2024-02-06 15:18:06 +00:00
|
|
|
const VoiceChannel = defineVoiceChannel(sequelize);
|
2024-02-07 20:02:37 +00:00
|
|
|
|
2024-02-06 15:18:06 +00:00
|
|
|
const Message = defineMessage(sequelize);
|
2024-02-07 20:02:37 +00:00
|
|
|
Message.hasMany(RoleEmojiPair, { foreignKey: 'message', onDelete: 'CASCADE' });
|
2024-02-06 15:18:06 +00:00
|
|
|
|
|
|
|
sequelize.sync();
|
|
|
|
export { sequelize, RoleEmojiPair, VoiceChannel, Message };
|