|
160 | 160 | | `npm run migrate` | Run any migration files which haven't run yet. |
|
161 | 161 | | `npm run migrate:undo` | Revert most recent migration. |
|
162 | 162 |
|
| 163 | +## Import and Export data |
| 164 | +
|
| 165 | +### 📤 Export data |
| 166 | +
|
| 167 | +To export data to the default file `data/demo-data.json`, run: |
| 168 | +```bash |
| 169 | +npm run data:export |
| 170 | +``` |
| 171 | +
|
| 172 | +If you want to export data to another file, run: |
| 173 | +
|
| 174 | +```bash |
| 175 | +npm run data:export -- --file path/to-file.json |
| 176 | +``` |
| 177 | +
|
| 178 | +- List of models that will be exported are defined in `scripts/data/exportData.js`. |
| 179 | +
|
| 180 | +### 📥 Import data |
| 181 | +
|
| 182 | +⚠️ This command would clear any existent data in DB and ES before importing. |
| 183 | +
|
| 184 | +*During importing, data would be first imported to the database, and after from the database it would be indexed to the Elasticsearch index.* |
| 185 | +
|
| 186 | +To import data from the default file `data/demo-data.json`, run: |
| 187 | +```bash |
| 188 | +npm run data:import |
| 189 | +``` |
| 190 | +
|
| 191 | +If you want to import data from another file, run: |
| 192 | +
|
| 193 | +```bash |
| 194 | +npm run data:import -- --file path/to-file.json |
| 195 | +``` |
| 196 | +
|
| 197 | +- List of models that will be imported are defined in `scripts/data/importData.js`. |
| 198 | +
|
163 | 199 | ## Kafka commands
|
164 | 200 |
|
165 | 201 | If you've used `docker-compose` with the file `local/docker-compose.yml` during local setup to spawn kafka & zookeeper, you can use the following commands to manipulate kafka topics and messages:
|
@@ -209,3 +245,22 @@ The following parameters can be set in the config file or via env variables:
|
209 | 245 |
|
210 | 246 | - Run `npm run test` to execute unit tests
|
211 | 247 | - Run `npm run cov` to execute unit tests and generate coverage report.
|
| 248 | +
|
| 249 | +## 📋 Code Guidelines |
| 250 | +
|
| 251 | +### General Requirements |
| 252 | +
|
| 253 | +- Split code into reusable methods where applicable. |
| 254 | +- Lint should pass. |
| 255 | +
|
| 256 | +### Documentation and Utils |
| 257 | +
|
| 258 | +When we add, update or delete models and/or endpoints we have to make sure that we keep documentation and utility scripts up to date. |
| 259 | +
|
| 260 | +- Update Swagger. |
| 261 | +- Update Postman. |
| 262 | +- Update mapping definitions for ElasticSearch indexes inside this repository and inside [taas-es-processor](https://github.com/topcoder-platform/taas-es-processor) repository. |
| 263 | +- NPM command `index:all` should re-index data in all ES indexes. And there should be an individual NPM command `index:*` which would re-index data only in one ES index. |
| 264 | +- NPM commands `data:import` and `data:export` should support importing/exporting data from/to all the models. |
| 265 | +- NPM commands `create-index` and `delete-index` should support creating/deleting all the indexes. |
| 266 | +- If there are any updates in DB schemas, create a DB migration script inside `migrations` folder which would make any necessary updates to the DB schema. Test, that when we migrate DB from the previous state using `npm run migrate`, we get the same exactly the same DB schema as if we create DB from scratch using command `npm run init-db force`. |
0 commit comments