Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pyritewolf authored May 5, 2020
1 parent c5f41a8 commit edb9c64
Showing 1 changed file with 2 additions and 87 deletions.
89 changes: 2 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

0 comments on commit edb9c64

Please sign in to comment.