Migrating from the old SciCat Backend
Where the current SciCat Backend accepts id fields in the database named pid
, doi
, or similar, this implementation requires there to be an id field of the form _id
on every document. It is therefore necessary to run a database migration script towards MongoDB instance from a place where you have access to it and can install migrate-mongo
package.
All database migration scripts are located in the migrations folder.
- To run the migrations locally you just need to install all dependencies and run
npm run start
which will run the migrations first and start the application. If you want to run the migrations manually you can installmigrate-mongo
package globally and runmigrate-mongo up
or if it is already installed locally because is part of the dependencies it is possible to just run:node ./node_modules/migrate-mongo/bin/migrate-mongo.js up
. - To run the migrations on the server you will need to copy the migration scripts together with
migrate-mongo-config.js
file to a location were you can access your MongoDB instance and havemigrate-mongo
package installed either globally(which is preferred) or locally if global installation is not possible. Then modify the config file to contain your MongoDB instance details like database name and url. Once modified, start the migration by running
migrate-mongo up
if migrate-mongo
is installed globally at the location where you want to run it from or if it is locally installed just run
./node_modules/migrate-mongo/bin/migrate-mongo.js up
Migration documentation and NestJs resources
Following are the post that I found useful working on the migration:
- Schema and DTOs: https://betterprogramming.pub/how-to-use-data-transfer-objects-dto-for-validation-in-nest-js-7ff95309f650
- Validation:
- Swagger and OpenAPI:
For the full documentation please go to the SciCat home page and follow the documentation link