-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: hxtree <[email protected]>
- Loading branch information
Showing
12 changed files
with
66 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. | ||
{ | ||
"pnpmShrinkwrapHash": "226112290342a77c7f773aeecbc45e260e27e9bc", | ||
"pnpmShrinkwrapHash": "789c7de00d79d30378a52f3bcfad002fc81af8d2", | ||
"preferredVersionsHash": "7c6836c4ff2ee31a263e87ea93a487fc752ca3f6" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
services/player-achievements/migrations/1701265134891_Migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Db } from 'mongodb'; | ||
import { MigrationInterface } from 'mongo-migrate-ts'; | ||
import { asyncForEach } from '@cats-cradle/nestjs-modules'; | ||
import { ObjectId, UUID } from 'bson'; | ||
import { v4 } from 'uuid'; | ||
import { Achievements } from '../src/models/achievements'; | ||
|
||
export class Migration1701265134891 implements MigrationInterface { | ||
public async up(db: Db): Promise<any> { | ||
await asyncForEach(Achievements, async (trophy: object) => { | ||
const record = { _id: new UUID(v4()) as any as ObjectId }; | ||
|
||
await db.collection('trophies').insertOne({ ...record, ...trophy }); | ||
}); | ||
} | ||
|
||
public async down(db: Db): Promise<any> { | ||
await asyncForEach(Achievements, async (trophy) => { | ||
await db.collection('trophies').deleteOne(trophy); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { mongoMigrateCli } from 'mongo-migrate-ts'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const username = process.env.MONGO_DATABASE_USER; | ||
const password = process.env.MONGO_DATABASE_PASSWORD; | ||
const MONGO_URI = `${process.env.MONGO_DATABASE_URI}`; | ||
|
||
const db = `${process.env.STAGE}-${process.env.APP_NAME}`; | ||
const uri = MONGO_URI.replace('//', `//${username}:${password}@`); | ||
|
||
mongoMigrateCli({ | ||
uri, | ||
database: db, | ||
migrationsDir: __dirname, | ||
migrationsCollection: 'migration_versions', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
services/player-achievements/src/migrations-utils/template.ts
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
services/player-achievements/src/migrations-utils/ts-compiler.js
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
services/player-achievements/src/migrations/1701140634237-trophy.ts
This file was deleted.
Oops, something went wrong.