add migrations
This commit is contained in:
parent
c38372a173
commit
e650e591d5
6 changed files with 163 additions and 0 deletions
55
migrations/001-initial.js
Normal file
55
migrations/001-initial.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
var db = require('./db');
|
||||
|
||||
exports.up = function(next){
|
||||
|
||||
var sqls = [
|
||||
'CREATE TABLE IF NOT EXISTS user_config ( ' +
|
||||
'id serial PRIMARY KEY, ' +
|
||||
'type text NOT NULL, ' +
|
||||
'data json NOT NULL ' +
|
||||
')',
|
||||
|
||||
'CREATE TABLE IF NOT EXISTS devices ( ' +
|
||||
'id serial PRIMARY KEY, ' +
|
||||
'fingerprint text NOT NULL UNIQUE, ' +
|
||||
'name text, ' +
|
||||
'authorized boolean, ' +
|
||||
'unpair boolean NOT NULL DEFAULT false' +
|
||||
')',
|
||||
|
||||
'CREATE TABLE IF NOT EXISTS pairing_tokens (' +
|
||||
'id serial PRIMARY KEY, ' +
|
||||
'token text, ' +
|
||||
'created timestamp NOT NULL DEFAULT now() ' +
|
||||
')',
|
||||
|
||||
'CREATE TABLE IF NOT EXISTS transactions ( ' +
|
||||
'id uuid PRIMARY KEY, ' +
|
||||
'status text NOT NULL, ' +
|
||||
'tx_hash text, ' +
|
||||
'device_fingerprint text, ' +
|
||||
'to_address text NOT NULL, ' +
|
||||
'satoshis integer, ' +
|
||||
'currency_code text, ' +
|
||||
'fiat decimal, ' +
|
||||
'error text, ' +
|
||||
'created timestamp NOT NULL DEFAULT now(), ' +
|
||||
'completed timestamp ' +
|
||||
')',
|
||||
|
||||
'CREATE TABLE IF NOT EXISTS users ( ' +
|
||||
'id serial PRIMARY KEY, ' +
|
||||
'userName text NOT NULL UNIQUE, ' +
|
||||
'salt text NOT NULL, ' +
|
||||
'pwdHash text NOT NULL ' +
|
||||
')'
|
||||
];
|
||||
|
||||
db.multi(sqls, next);
|
||||
};
|
||||
|
||||
exports.down = function(next){
|
||||
next();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue