Closed silverpedak closed 1 year ago
@silverpedak I have the same issue, can you publish the solution please? Thanks!
Try changing the migrationsDir in your mongoMigrateCli to "build/migrations".
In the root dir of your project, compile the Typescript code with tsc
.
You should have a /build folder now, that contains the compiled code.
Run the code with node build/index.js up
.
my src/index.ts
import { mongoMigrateCli } from "mongo-migrate-ts";
mongoMigrateCli({
uri: your-mongo-URL,
database: "your-db-name",
migrationsDir: "build/migrations",
migrationsCollection: "migrations_collection",
});
my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["es6"],
"allowJs": true,
"outDir": "build",
"rootDir": "src",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true
}
}
Hope this helps
Thanks @silverpedak for your reply!
Actually, because I first manually altered the DB, I wanted to run the down
migration first... because no migration had previously ran, nothing was stored in the migration_changelog
collection, so no migration could be undone. After running a up
migration, I was able to run the down
migration without any issue.
Steps I have taken
index.ts
migrations/migration_1.ts
response: ⚠ No migrations found
Tryed installing globally and using CLI, resilt is the same