<FromGitter>
<sam0x17> in granite how to get just the first record in a query?
<FromGitter>
<Blacksmoke16> `.first` is a thing
<FromGitter>
<Blacksmoke16> er
<FromGitter>
<Blacksmoke16> `.find_by`, and `find` use `.first` under the hood
<FromGitter>
<Blacksmoke16> otherwise you can pass some raw sql to `.first`
<FromGitter>
<John-Hayes-Reed> Hi all, sorry for the complete n00b question, just started playing around with Crystal and Amber the other day. Got a simple app up and running, however the test DB doesn't get created on app creation and I can't seem to find how to create that through the CLI. Is there a way for me to just create the test DB without having to go in and manually create it through postgres?
<FromGitter>
<drujensen> you can create it using `AMBER_ENV=test amber db drop create migrate`
<FromGitter>
<drujensen> this is similar to rails
<FromGitter>
<John-Hayes-Reed> I thought that would have been the case, but just doesn't seem to want to pick up that env var for me, will do some more digging
<FromGitter>
<John-Hayes-Reed> root@e81013eefb23:/app# AMBER_ENV=test; echo $AMBER_ENV ⏎ test ⏎ root@e81013eefb23:/app# AMBER_ENV=test; amber db create ⏎ database "xxxxxxxx_development" already exists ⏎ root@e81013eefb23:/app# AMBER_ENV=test amber db create ... [https://gitter.im/amberframework/amber?at=5e825f81964124415785dd6e]
<FromGitter>
<drujensen> hhmm, i just tried it on my project and it worked. Can you check your `config/environments/test.yml` and verify the `database_url:` is test correctly?
<FromGitter>
<John-Hayes-Reed> yep, set to `_test`
<FromGitter>
<drujensen> in your `config/database.cr`, it is using `Amber.settings.database_url`?
<FromGitter>
<John-Hayes-Reed> it is indeed
<FromGitter>
<drujensen> I don’t think we use `DATABASE_URL` environment variable anymore
<FromGitter>
<drujensen> so kinda stumped. Can you try adding `p ">>>>> #{Amber.settings.database_url}”`
<FromGitter>
<drujensen> to your config/database.cr?
<FromGitter>
<drujensen> see what it prints out
<FromGitter>
<drujensen> oh, wait. nm
<FromGitter>
<drujensen> hhmm
<FromGitter>
<drujensen> can you look in your `spec/spec_helper.cr` and make sure its using `Amber.settings.database_url`?
<FromGitter>
<drujensen> hhmm, nm, i’m stumped
<FromGitter>
<drujensen> aah
<FromGitter>
<John-Hayes-Reed> Yes it is using it in spec helper as well
<FromGitter>
<drujensen> the CLI is still looking for `DATABASE_URL`
<FromGitter>
<drujensen> do you have an environment variable set?
<FromGitter>
<John-Hayes-Reed> ahhh, yes, the `app` service in the docker-compose file is passing through the `DATABASE_URL` and that is set to `_development`
<FromGitter>
<John-Hayes-Reed> So I guess that is taking priority? and I need to take that out?
<FromGitter>
<drujensen> ok, this is a bug
<FromGitter>
<drujensen> yeah, take that out. We probably should remove the DATABASE_URL from the cli tool
<FromGitter>
<John-Hayes-Reed> Boom, that did the trick, test database now created
<FromGitter>
<drujensen> great. Do you mind reporting a bug in github?
<FromGitter>
<John-Hayes-Reed> No problem, will report an issue in github now
<FromGitter>
<drujensen> thank you!
<FromGitter>
<John-Hayes-Reed> https://github.com/amberframework/amber/issues/1190 ⏎ ^^^^ Hope that is okay, first time creating an issue so do let me know if you need me to add anything to it or if the format / content is all off.
<FromGitter>
<drujensen> Well done. Way Better than most bugs reported.