-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5f41a8
commit edb9c64
Showing
1 changed file
with
2 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,91 +2,6 @@ | |
|
||
[![Build Status](https://travis-ci.org/instedd/maap-collector.svg?branch=master)](https://travis-ci.org/instedd/maap-collector) | ||
|
||
## Development environment | ||
A desktop app for health data collection, to be used along [maap-store](https://github.com/instedd/maap-store). | ||
|
||
Prepare your dev environment by setting node to version 10.15.3: | ||
|
||
``` | ||
$ npm install -g [email protected] | ||
``` | ||
|
||
Install [sqlite](https://sqlite.org/index.html) and [sqlcipher](https://www.zetetic.net/sqlcipher/) locally: | ||
|
||
``` | ||
$ brew install sqlite | ||
$ brew install sqlcipher | ||
``` | ||
|
||
- Install dependencies with yarn. | ||
- Start the app in the `dev` environment. | ||
|
||
``` | ||
$ yarn | ||
$ yarn dev | ||
``` | ||
|
||
### Useful commands | ||
|
||
``` | ||
# Identify any issues in staged files | ||
$ yarn precommit | ||
# Run tests | ||
$ yarn build-e2e | ||
$ yarn test-e2e | ||
``` | ||
|
||
## Migrations | ||
|
||
Migrations are based on Sequelized's Umzug library. So if there's anything missing here, try taking a look at: https://github.com/sequelize/umzug. | ||
|
||
When you introduce a schema change, you should add a migration to the `app/db/migrations` folder. | ||
Please number them sequentially (`xxx_some_descriptive_migration_name`), and pay attention to clashes with upstream when | ||
merging. | ||
|
||
Migrations should be modules that export `up` and `down` functions like this one: | ||
|
||
```javascript | ||
module.exports = { | ||
up: function(query, DataTypes) { | ||
return query.createTable('test', { | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true | ||
}, | ||
firstName: { | ||
type: DataTypes.TEXT | ||
}, | ||
lastName: { | ||
type: DataTypes.TEXT | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
} | ||
}); | ||
}, | ||
down: function down(query, DataTypes) { | ||
return query.dropTable('test'); | ||
} | ||
}; | ||
``` | ||
|
||
`query` is a query interface to the live, unencrypted database exposed through a Sequelize instance, | ||
so you can run any Sequelize query as part of your migrations. | ||
|
||
IMPORTANT: don't use model classes, as those evolve with code. Remember migrations work against the database, | ||
so you can't assume anything about the concrete version of the code you're running. | ||
|
||
Migrations will be checked and run everytime the app starts, provided the user has succeeded in opening the database. | ||
|
||
`up` and `down` functions are regular Javascript code, so you can run any other upgrade processes inside migrations. | ||
|
||
Whenever you modify the schema, take into account how the data should evolve from the previous schema version to the one | ||
you're introducing (e.g.: if you're adding a column, should you be setting a default value for existing rows?). | ||
Head over to the [project's wiki](https://github.com/instedd/maap-collector/wiki) to learn how to set up a local environment and find useful technical information! |