diff --git a/lib/constants.js b/lib/constants.js new file mode 100644 index 00000000..e7cff197 --- /dev/null +++ b/lib/constants.js @@ -0,0 +1,6 @@ +const anonymous_customer = { + uuid : '47ac1184-8102-11e7-9079-8f13a7117867', + name: 'anonymous', +} + +module.exports = {anonymous_customer} diff --git a/migrations/036-add_customers_table.js b/migrations/036-add_customers_table.js index 445e9223..4202914f 100644 --- a/migrations/036-add_customers_table.js +++ b/migrations/036-add_customers_table.js @@ -1,4 +1,5 @@ var db = require('./db') +var anonymous = require('../lib/constants').anonymous_customer exports.up = function(next) { const sql = @@ -20,8 +21,9 @@ exports.up = function(next) { id_card_image_path text, id_card_image_at timestamptz, created timestamptz NOT NULL DEFAULT now() )`, - `alter table cash_in_txs add column customer_id uuid references customers (id)`, - `alter table cash_out_txs add column customer_id uuid references customers (id)` + `insert into customers (id, name) VALUES ( '${anonymous.uuid}','${anonymous.name}' )`, + `alter table cash_in_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`, + `alter table cash_out_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`, ] db.multi(sql, next)