Skip to content

Commit 3b156c1

Browse files
committed
Added migrations instructions
1 parent ea92bca commit 3b156c1

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

docs/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,35 @@ You can add additional functionality to your application via building your own w
101101
## Environment variables
102102

103103
Have a look at the [docker-compose.yml](../deployment/docker/docker-compose.yml) file to know what all environment variables are available for you to tweak.
104+
105+
## Applying DB Migrations
106+
107+
The migrations are located in the [apps/web/.migrations](../apps/web/.migrations) directory. The migrations are named like `DD-MM-YY_HH-MM-<migration-purpose>.js` so that they can be sorted chronologically.
108+
109+
### To Apply a Migration
110+
111+
Since the migrations are complete scripts, you need to have some development chops—not much, though.
112+
113+
1. Initialize a blank Node project. In your terminal, create a blank Node project:
114+
115+
```
116+
mkdir migration
117+
cd migration
118+
npm init -y
119+
```
120+
121+
2. Install dependencies.
122+
123+
You can refer to the first few lines of the migration to see which dependencies are required. Most of the time, you'll be good to go after running the following command:
124+
125+
```
126+
npm i mongoose nanoid
127+
```
128+
129+
3. Copy the migration script into this new project folder.
130+
131+
4. Run the script:
132+
133+
```
134+
DB_CONNECTION_STRING=mongodb://<mongodb-url> node migration-script.js
135+
```

0 commit comments

Comments
 (0)