forked from PluralFlux/PluralFlux
feat: add db migrations with typeORM (#28)
* adding typescript packages for typeORM * add typeORM initial files * updating package scripts * updating compose.yaml to have an exposed port for the postgres * modifying setup for typeORM * update database stuff and and package.json to help generate migrations * made models and migrations in typeORM * delete unneeded database.js * made database pattern ignored by jest * remove sequelize * separate member repo from member helper * not sure why i made everything numbers in the model but it's fixed now * edited package.json script * remove unused index.ts * adjusted files to reference repository correctly and appdatasource * made appdatasource export as named * removed start-db script * added init to appdatasource in bot.js * migrations finally! * new migration matching model names I want * updating tests * removing testpathignore patterns since it seems to be unecessary? * adjusting migrations to match current schema * removed reference to secrets file * delete old migration * Revert "delete old migration" This reverts commit db1efa39a7a80d8976878856250ccaac6a753ab2. * Revert "adjusting migrations to match current schema" This reverts commit ef89a83f6a2ef0643d6ace0a3fcf9c40f4bc6dd6. * just deleted system creation since it's got nothing in it anyway * renamed memberRepository to memberRepo for consistency * added await back to parseMemberCommand call to memberArgumentHandler * changed call to memberHelper.getMembersByAuthor to memberRepo * renamed repo updateMemberValue to updateMemberField * removed throw references in repo docstrings * remove unneeded subscriber directory ref * changed createdAt and updatedAt columns to be auto-generated made member table have timezone * changed casing of isInitialized in mock for bot.js * removed % from ILike query so that it doesn't match substrings/wildcard * renamed some stray updateMemberValue in mocks -> updateMemberField --------- Co-authored-by: Aster Fialla <asterfialla@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ const {commands} = require("./commands.js");
|
||||
const {webhookHelper} = require("./helpers/webhookHelper.js");
|
||||
const env = require('dotenv');
|
||||
const {utils} = require("./helpers/utils.js");
|
||||
const { AppDataSource } = require("../database/data-source");
|
||||
|
||||
env.config();
|
||||
|
||||
@@ -20,7 +21,7 @@ client = new Client({ intents: 0 });
|
||||
module.exports.client = client;
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
await handleMessageCreate(message);
|
||||
await module.exports.handleMessageCreate(message);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -85,8 +86,10 @@ const debouncePrintGuilds = utils.debounce(printGuilds, 2000);
|
||||
|
||||
module.exports.login = async function() {
|
||||
try {
|
||||
if (!AppDataSource.isInitialized) {
|
||||
await AppDataSource.initialize();
|
||||
}
|
||||
await client.login(token);
|
||||
// await db.check_connection();
|
||||
} catch (err) {
|
||||
console.error('Login failed:', err);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user