From d3bfdac4cd53681a8209759b2fa4c3ae2a09e944 Mon Sep 17 00:00:00 2001 From: Elad Lachmi Date: Thu, 8 Mar 2018 23:47:34 +0200 Subject: [PATCH] Fix ticket sync from Drupal (#734) * 1. Removed requirement for barcode to exist in Drupal ticket 2. Made barcode column nullable --- .../20180308221834_ticket_barcode_nullable.js | 16 ++++++++++++++++ scripts/drupal_ticket_sync.js | 9 ++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 migrations/20180308221834_ticket_barcode_nullable.js diff --git a/migrations/20180308221834_ticket_barcode_nullable.js b/migrations/20180308221834_ticket_barcode_nullable.js new file mode 100644 index 000000000..20ce7be90 --- /dev/null +++ b/migrations/20180308221834_ticket_barcode_nullable.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.alterTable('tickets', t => { + t.string('barcode', 32).nullable().alter() + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.alterTable('tickets', t => { + t.string('barcode', 32).notNullable().alter() + }) + ]) +}; diff --git a/scripts/drupal_ticket_sync.js b/scripts/drupal_ticket_sync.js index 33d7d643a..092da8e15 100644 --- a/scripts/drupal_ticket_sync.js +++ b/scripts/drupal_ticket_sync.js @@ -147,12 +147,7 @@ async function updateTicket(ticket) { ticket_type } = ticket; - if (typeof barcode !== 'string' || barcode.length === 0) { - log.info('No barcode for ticket', ticket_id, 'user ', holder_email); - return; - } else { - log.info('Updating ticket', ticket_id, 'user ', holder_email); - } + log.info('Updating ticket', ticket_id, 'user ', holder_email); try { var user = await User.forge({email: holder_email}).fetch(); @@ -198,7 +193,7 @@ async function updateTicket(ticket) { sparkTicket = Ticket.forge({ event_id: EVENT_ID, holder_id: holder_id, - barcode: barcode, + barcode: (typeof barcode !== 'string' || barcode.length === 0) ? null : barcode, order_id: order_id, ticket_id: ticket_id, type: ticket_type,