feat: add migration to add customer custom fields related tables

feat: create CustomerCustomField type on graphql
feat: add custom fields fetching to getCustomer and getCustomerList functions
feat: add mutations to interact with customer custom fields
This commit is contained in:
Sérgio Salgado 2021-09-06 16:45:02 +01:00
parent 0035684040
commit fec57bf173
4 changed files with 118 additions and 8 deletions

View file

@ -0,0 +1,23 @@
var db = require('./db')
exports.up = function (next) {
var sql = [
`CREATE TABLE custom_field_definitions (
id UUID PRIMARY KEY,
label TEXT NOT NULL UNIQUE,
active BOOLEAN DEFAULT true
)`,
`CREATE TABLE customer_custom_field_pairs (
customer_id UUID REFERENCES customers(id) NOT NULL,
custom_field_id UUID REFERENCES custom_field_definitions(id) NOT NULL,
value TEXT NOT NULL,
UNIQUE (customer_id, custom_field_id)
)`,
]
db.multi(sql, next)
}
exports.down = function (next) {
next()
}