Merge pull request #838 from chaotixkilla/feat-add-backend-support-customer-custom-fields
Add backend support to customer custom fields
This commit is contained in:
commit
abd3bcc625
5 changed files with 122 additions and 8 deletions
23
migrations/1630624117042-customer-custom-fields.js
Normal file
23
migrations/1630624117042-customer-custom-fields.js
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue