dougestey / toronto-city-hall-api

Powering municipal apps in Toronto.
5 stars 2 forks source link

Setup instructions incomplete? #3

Closed patcon closed 9 years ago

patcon commented 9 years ago

Went through the instructions as provided.

Configure the connection you wish to use in config/connections.js

Doesn't seem to be anything in here to select, if we're using sails-disk. Presumably you mean in an env file like config/env/development.js? I changed the commented line here: https://github.com/designcofounders/toronto-city-hall-api/blob/master/config/env/development.js#L21-L22

Then ran:

# env defaults to "development" according to `sails-migrations --help`
$ sails-migrations migrate
Error: undefined is not a valid Knex client, did you misspell it?
    at Knex.initialize (/non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/node_modules/knex/knex.js:103:13)
    at Knex (/non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/node_modules/knex/knex.js:13:26)
    at /non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/lib/sails-migrations/helpers/migrator_loader.js:7:12
From previous event:
    at Object.getConfig [as load] (/non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/lib/sails-migrations/helpers/config_loader.js:73:61)
    at Object.load (/non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/lib/sails-migrations/helpers/migrator_loader.js:5:23)
    at Object.latest [as migrate] (/non_encrypted/repos/toronto-city-hall-api/node_modules/sails-migrations/lib/sails-migrations/migrate_to_latest.js:7:25)
    at Command.<anonymous> (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/bin/cli.js:82:10)
    at Command.listener (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/node_modules/commander/index.js:287:8)
    at Command.emit (events.js:98:17)
    at Command.parseArgs (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/node_modules/commander/index.js:541:12)
    at Command.parse (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/node_modules/commander/index.js:427:21)
    at Liftoff.invoke (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/bin/cli.js:164:13)
    at Liftoff.launch (/home/patcon/.npm-packages/lib/node_modules/sails-migrations/node_modules/liftoff/index.js:163:8)

Any offhand thoughts on what's up?

EDIT: Oops. Pasted wrong output

patcon commented 9 years ago

OK, tried with redis too, and the same error. (My postgres has been broken for ages, so I always use VM's for that, but was hoping to avoid that for a node app)

patcon commented 9 years ago

Just so I know I'm not crazy and don't spin my wheels any longer, can you help me do a sanity check and reclone the project into /tmp or something and let me know if the sails-disk instructions work? :)

dougestey commented 9 years ago

Just recloned on my Windows box - it's working as expected, but I realized that my instructions were confusing. You don't need to run sails-migrations for sails-disk, as it is a nosql solution that creates relations as needed. So you just need to sails lift and continue along your merry way.

Docs updated. Let me know if this works!

patcon commented 9 years ago

OK, cool. I guess no data is possible with sails-disk, but I can get empty array responses via curling

localhost:1337/councillor
localhost:1337/ward
localhost:1337/user
localhost:1337/motion

I guess that's the most I can expect to see without getting a db like mysql working, huh? Anyhow, thanks doug. I'll get on that later

dougestey commented 9 years ago

Data is indeed possible with sails-disk, it's just not an adaptor that's compatible with sails-migrations. You don't need to create tables with sails-disk as relations are created on the fly, so things like migrations are irrelevant anyway :)

Both setups right now leave you with an empty db with working endpoints, and if you were to POST to any of the endpoints you mentioned above you'd have data coming back & sails-disk handling persistence.

This comes back to the problem of working out the best way to bootstrap people with a starting db. But for now you can reference the examples in db/init and drop those into config/bootstrap.js on your first sails-lift to populate the DB that way.

dougestey commented 9 years ago

Over lunch today I pushed a postgres db snapshot & associated instructions to the repo. On the weekend I'll use this data to generate a Waterline script so people can get up and running on any adaptor.