Skip to content

Commit

Permalink
Merge pull request #181 from Skript-MC/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
noftaly authored Feb 20, 2022
2 parents cccfeb6 + 800635e commit 3a256a9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion tools/update-databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,28 @@ import 'source-map-support/register';
import 'module-alias/register';
import 'dotenv/config';

console.log('No migration needed');
import mongoose from 'mongoose';
import Sanction from '../src/models/sanction';

async function start(): Promise<void> {
console.log('Connecting to database...');

await mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
mongoose.connection.on('connected', () => {
console.log('MongoDB is connected!');
});
mongoose.connection.on('error', (err) => {
console.error('MongoDB connection error. Please make sure MongoDB is running.');
throw err;
});

console.log('Converting...');
await Sanction.updateMany({ type: 'ban' }, { 'informations.hasSentMessages': true });
console.log('Conversion was successful!');
// eslint-disable-next-line node/no-process-exit
process.exit(0);
}
void start();

0 comments on commit 3a256a9

Please sign in to comment.