-
Notifications
You must be signed in to change notification settings - Fork 1
Development setup
This project has been developed with Electron, ReactJS and SQLite. The main use is carried out in laptops with limited resources, limited connectivity and Windows OS, so those are the main concerns in the code.
Prepare your dev environment by setting node to version 10.15.3:
$ npm install -g [email protected]
Install sqlite and sqlcipher locally:
$ brew install sqlite
$ brew install sqlcipher
- Install dependencies with yarn.
- Start the app in the
dev
environment.
$ yarn
$ yarn dev
# Identify any issues in staged files
$ yarn precommit
# Run tests
$ yarn build-e2e
$ yarn test-e2e
While this application can work in standalone mode, you may want to configure the store project (the back-office where site information is configured) to have the complete landscape of the application's use.
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:
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?).
Sometimes SQLite database gets corrupted. If that's so, you can open DevTools in Collector app and type:
const { remote } = require('electron')
`${remote.app.getPath('userData')}/maap/app/db/storage/`
This will output the path to database files in the host. Log out from the application and delete them. After logging in again, a clean brand new database will be created.