-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/virus-scanner-integration
- Loading branch information
Showing
37 changed files
with
8,594 additions
and
1,075 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
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 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 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 |
---|---|---|
|
@@ -9,27 +9,32 @@ | |
[![Coverage Status](https://coveralls.io/repos/github/opengovsg/FormSG/badge.svg?branch=develop)](https://coveralls.io/github/opengovsg/FormSG?branch=develop) | ||
|
||
## Table of Contents | ||
|
||
- [FormSG](#formsg) | ||
- [Table of Contents](#table-of-contents) | ||
- [Contributing](#contributing) | ||
- [Features](#features) | ||
- [Local Development (Docker)](#local-development-docker) | ||
- [Prerequisites](#prerequisites) | ||
- [First Setup](#first-setup) | ||
- [Running Locally](#running-locally) | ||
- [Accessing email locally](#accessing-email-locally) | ||
- [Environment variables](#environment-variables) | ||
- [Trouble-shooting](#trouble-shooting) | ||
- [Testing](#testing) | ||
- [Testing Prerequisites](#testing-prerequisites) | ||
- [Running tests](#running-tests) | ||
- [Unit tests](#unit-tests) | ||
- [End-to-end tests](#end-to-end-tests) | ||
- [Architecture](#architecture) | ||
- [MongoDB Scripts](#mongodb-scripts) | ||
- [Support](#support) | ||
- [Acknowledgements](#acknowledgements) | ||
- [Contributing](#contributing) | ||
- [IMPORTANT NOTE TO ALL CONTRIBUTORS](#important-note-to-all-contributors) | ||
- [Features](#features) | ||
- [Local Development (Docker)](#local-development-docker) | ||
- [Prerequisites](#prerequisites) | ||
- [First Setup](#first-setup) | ||
- [Running Locally](#running-locally) | ||
- [Adding dependencies](#adding-dependencies) | ||
- [Accessing email locally](#accessing-email-locally) | ||
- [Environment variables](#environment-variables) | ||
- [Trouble-shooting](#trouble-shooting) | ||
- [Testing](#testing) | ||
- [Testing Prerequisites](#testing-prerequisites) | ||
- [Running tests](#running-tests) | ||
- [Unit tests](#unit-tests) | ||
- [End-to-end tests](#end-to-end-tests) | ||
- [Cross-browser testing](#cross-browser-testing) | ||
- [Architecture](#architecture) | ||
- [MongoDB Scripts](#mongodb-scripts) | ||
- [Support](#support) | ||
- [Database Alternatives](#database-alternatives) | ||
- [Migrating from Mongoose ODM to Prisma ORM](#migrating-from-mongoose-odm-to-prisma-orm) | ||
- [Replacing MongoDB with CockroachDB](#replacing-mongodb-with-cockroachdb) | ||
- [Other Prisma supported DBs](#other-prisma-supported-dbs) | ||
- [Other potential DB migrations](#other-potential-db-migrations) | ||
- [Acknowledgements](#acknowledgements) | ||
|
||
## Contributing | ||
|
||
|
@@ -217,6 +222,51 @@ Scripts for common tasks in MongoDB can be found [here](docs/MONGODB.md). | |
|
||
Please contact FormSG ([email protected]) for any details. | ||
|
||
## Database Alternatives | ||
|
||
### Migrating from Mongoose ODM to Prisma ORM | ||
|
||
FormSG uses Mongoose as the Object-Document Mapping (ODM) to MongoDB. This means that our code is strongly coupled with MongoDB as Mongoose solely supports it. | ||
|
||
In order to use a different database with FormSG you will have to first migrate from Mongoose to other object modelling libraries. One of which is Prisma. | ||
|
||
Prisma is an Object-Relational Mapping (ORM) library that can also be used as the object model for MongoDB. Prisma is compatible with various other relational databases like Cockroach DB. | ||
|
||
Follow this [guide](https://www.prisma.io/docs/guides/migrate-to-prisma/migrate-from-mongoose#overview-of-the-migration-process) by Prisma to migrate from Mongoose. | ||
|
||
The guide has 4 primary steps: | ||
1. Install Prisma CLI | ||
2. Introspect the current MongoDB for the data model | ||
1. For this section, Prisma’s introspection should be able to create prisma models that will replace your `server.model.ts` for each collection | ||
2. Additionally, as Prisma is relational, you could add relations between the various documents. One good relation to add will be `form` many to one `user` on the `[form.email](http://form.email)` field. | ||
3. Install Prisma Client | ||
4. Replace Mongoose Queries with Prisma Client | ||
1. This step will likely take the most refactoring efforts | ||
2. This will include most files in `formsg/src` ending with `service.ts` | ||
3. Including test files ending with `service.spec.ts` | ||
|
||
#### Replacing MongoDB with CockroachDB | ||
|
||
Thereafter, you could set up CockroachDB which is a distributed SQL DB. Follow the quick start guide by [CockroachDB](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart) to create a CockroachDB Serverless cluster. | ||
|
||
To replace the local development instance, you can follow this [guide](https://www.cockroachlabs.com/docs/stable/start-a-local-cluster-in-docker-mac). As FormSG uses Docker for local development, you will have to replace the `mongoDB` container from `docker-compose.yml` to the `cockroachDB` version. | ||
|
||
Then connect to [CockroachDB](https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-typescript-postgresql) by changing the DB url in `.env` to the one from your CockroachDB `DATABASE_URL="YOUR_COCKROACH_DB_URL"`. | ||
|
||
For local development, if the DB is replaced as above, you should not need to modify the ports as it will still be hosted on `localhost:27017`. | ||
|
||
#### Other Prisma supported DBs | ||
|
||
MongoDB can be replaced with other various relational databases supported by Prisma in this [list](https://www.prisma.io/docs/reference/database-reference/supported-databases). | ||
|
||
### Other potential DB migrations | ||
|
||
It is also possible to migrate from Mongoose to [Ottoman](https://ottomanjs.com/), which is another ODM. | ||
|
||
The process will be simpler than migrating to Prisma, but Ottoman is more restrictive and can only be used together with Couchbase, which is also a noSQL DB like MongoDB. | ||
|
||
Refer to this [guide](https://www.couchbase.com/blog/migrate-mongodb-mongoose-couchbase-ottoman/) to migrate from Mongoose to Ottoman and then replace MongoDB with Couchbase. | ||
|
||
## Acknowledgements | ||
|
||
FormSG acknowledges the work done by [Arielle Baldwynn](https://github.com/whitef0x0) to build and maintain [TellForm](https://github.com/tellform), on which FormSG is based. | ||
|
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
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,7 +1,7 @@ | ||
{ | ||
"name": "FormSG", | ||
"description": "Form Manager for Government", | ||
"version": "6.74.1", | ||
"version": "6.77.0", | ||
"homepage": "https://form.gov.sg", | ||
"authors": [ | ||
"FormSG <[email protected]>" | ||
|
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
Oops, something went wrong.