untoldone / bloomapi

Create APIs out of public datasources
https://www.bloomapi.com/documentation/public-data
MIT License
89 stars 29 forks source link

Ugly error when bootstrapping an already bootstrapped environment #38

Closed marks closed 10 years ago

marks commented 10 years ago

I think this should fail in a more user-friendly way.

mba62:marks-bloomapi mark$ node make bootstrap 
2013-09-28T18:48:11.137Z - info: bootstrapping bloomapi
2013-09-28T18:48:11.142Z - info: building website
2013-09-28T18:48:11.362Z - info: updating NPI datasources
2013-09-28T18:48:11.791Z - info: syncing NPI files NPPES_Data_Dissemination_Sep_2013
2013-09-28T18:48:11.793Z - info: syncing NPI files NPPES_Data_Dissemination_090913_091513_Weekly
2013-09-28T18:48:11.794Z - info: syncing NPI files NPPES_Data_Dissemination_091613_092213_Weekly
2013-09-28T18:50:39.895Z - info: syncing new NPI data files
2013-09-28T18:50:40.191Z - info: creating new NPI table with latest monthly dissemination
2013-09-28T19:12:02.660Z - info: updating 15802 NPI records
2013-09-28T19:12:44.895Z - info: updating 16674 NPI records

mba62:marks-bloomapi mark$ node make bootstrap 
2013-09-28T20:23:38.259Z - info: bootstrapping bloomapi
2013-09-28T20:23:38.262Z - info: building website
Error:
 error: type "source_status" already exists
    at Connection.parseE (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/pg/lib/connection.js:537:11)
    at Connection.parseMessage (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/pg/lib/connection.js:382:17)
    at Socket.<anonymous> (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/pg/lib/connection.js:97:20)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:736:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
From previous event:
    at defer (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/q/q.js:552:19)
    at Promise.then (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/q/q.js:792:20)
    at Function.target.bootstrap (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/make.js:47:6)
    at Object.target.(anonymous function) [as bootstrap] (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/shelljs/make.js:28:26)
    at /Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/shelljs/make.js:38:20
    at Array.forEach (native)
    at null._onTimeout (/Users/mark/Box Documents/Mark-Dev/marks-bloomapi/node_modules/shelljs/make.js:36:10)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
untoldone commented 10 years ago

If bootstrap tasks have already completed (bootstrap currently bootstraps and fetches) -- can always run node make fetch right now but I agree that bootstrap should either fail more gracefully or be re-runable to start from scratch again.

marks commented 10 years ago

@untoldone - I'm thinking just fail with an error like "Looks like you already have your bloomapi database set up. To update the database, run node make fetch."

untoldone commented 10 years ago

Sounds good to me

marks commented 10 years ago

Just a note. My patch fixes the current issue however a more long term solution would be to use database migrations. Never done that in node so letting someone else with more experience jump in.

untoldone commented 10 years ago

@marks Thanks for the fix!