<FromGitter>
<eliasjpr> Hello Sergio, I do not believe that’s is normal behavior for the amber watch command
<FromGitter>
<eliasjpr> @drujensen @Blacksmoke16 while setting up a model for an app I noticed that defining a uuid field is kind of strange and the type system@l for it is broken
<FromGitter>
<eliasjpr> First why if the field is an uuid we have to specify String as the type? This can have some unintended consequences since the a String does not necessarily conform to UUID format
<FromGitter>
<eliasjpr> Second there is nothing in Granite that validates the primary uuid as a uuid unless you write your own validation
<FromGitter>
<Blacksmoke16> its because granite doesn't support custom types
<FromGitter>
<Blacksmoke16> and `DB::Any` doesn't include `UUID`
<FromGitter>
<Blacksmoke16> so was a temp workaround to at least auto generate a uuid w/o a callback
<FromGitter>
<Blacksmoke16> @eliasjpr
<FromGitter>
<Blacksmoke16> but yes, that would ideally be the way to go
<FromGitter>
<eliasjpr> Kk I figure it was something like that
<FromGitter>
<Blacksmoke16> *yet*
<FromGitter>
<Blacksmoke16> PR would be welcome ofc :P
<FromGitter>
<Blacksmoke16> but its not trivial and part of a larger discussion as some DBs dont support native UUID types
<FromGitter>
<Blacksmoke16> so would need to register converters for each DB so everything converts correctly
<FromGitter>
<Blacksmoke16> or throw a compile time error like `MySQL does not support UUID type`
<FromGitter>
<Blacksmoke16> might have better luck in the #crystal channel
<FromGitter>
<Blacksmoke16> i unfortunately never used it :/
<FromGitter>
<grantspeelman> cool, will give that channel a try as well. thx
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<damianham> > Hi everyone - do you know if restarting `amber watch` is supposed to delete all my DB records? ⏎ Hi @sergiotapia it is a simple fix - open .amber.yml and prepend AMBER_ENV=test before crystal spec, see #1068 ⏎ @drujensen @eliasjpr I think merging #1068 might be a bit urgent
<FromGitter>
<anamba> it's been a while since i've created a new app. the default spec helper doesn't set AMBER_ENV?
<FromGitter>
<anamba> if you have to remember to set it yourself anytime you run `crystal spec` you are definitely going to forget at an inopportune moment
<FromGitter>
<damianham> yes - but by that time AMBER_ENV already has the value 'development'
<FromGitter>
<damianham> the operator is ||= so it is only set to test if it does not have a value
<FromGitter>
<anamba> ... why would that be
<FromGitter>
<anamba> it should be the very first line of code
<FromGitter>
<damianham> I presume because it is kicked of by the amber watch command and so the default AMBER_ENV has already been setup to development
<FromGitter>
<anamba> unless you actually have the environment variable set already
<FromGitter>
<damianham> no I don't have it set in my environment. I didn't dig too deeply but the way I see it amber watch is running crystal spec
<FromGitter>
<anamba> i suppose it could actually be better to have it not use ||=, and just use regular =
<FromGitter>
<damianham> yes that is another option, either way the app template needs changing so it doesn't bite people
<FromGitter>
<anamba> aha... i didn't expect that amber would actually set the env var but indeed, it does. so you are right, it is because the env var is set to 'development' by amber watch that it is already set by the time the spec_helper runs
<FromGitter>
<damianham> I suggest changing the .amber.yml template rather than the spec_helper.cr as this problem is a consequence of running crystal spec from amber watch as configured in .amber.yml so prepending the environment fixes the problem #1068 . if you change the spec_helper you will not be able to run AMBER_ENV=other_env crystal spec on the command line
<FromGitter>
<anamba> well, like the .amber.yml, you can feel free to change your own spec_helper anytime, but for both, we probably want the default to value safety over flexibility. plus i would expect that 99% of devs (and 100% of amber newcomers) would want AMBER_ENV to be "test" when running specs.
<FromGitter>
<anamba> so changing the defaults for both would be good i think. you can always change it after generating your app. and advanced users could make their own recipe.
<FromGitter>
<damianham> I think #1068 fixes the problem so I don't see the need to change spec_helper.cr but you are right - anyone wanting to set a specific test environment would be able to change the spec_helper.cr accordingly
<FromGitter>
<anamba> #1068 fixes a specific problem, and that's of course good in itself
<FromGitter>
<anamba> just wondering whether anyone would ever want to run `AMBER_ENV=development crystal spec` or `AMBER_ENV=production crystal spec`. (people who use custom environments other than the usual 3 have their work cut out for them anyway and they know that.)
<FromGitter>
<damianham> Well you certainly wouldn't want to do that with Model.clear in the specs :) but yes there are circumstances where you want to run the specs in a production environment
<FromGitter>
<damianham> obviously not with the production database - but rather a copy
<FromGitter>
<anamba> that sounds way too exciting for me. i am imagining lots of emails going out, APIs being called, errors going to sentry, etc.
<FromGitter>
<damianham> mocks can help with that though
<FromGitter>
<damianham> but one of the reasons to test in production mode is to test real API access - for example that the API hasn't changed
<FromGitter>
<damianham> config/environments/development.yml - set auto_reload to false
feepbot has quit [Ping timeout: 255 seconds]
feepbot has joined #amber
<FromGitter>
<alex-lairan> Oh, ok i've forgot to change the env ! :')
<FromGitter>
<silmanduin66> Hi there, i'm trying to deploy my amber app on heroku . It uses postgresql as a database and i get this ```'localhost:5432': Connection refused (Errno)``` error. Does anyone know how to solve that ?
<FromGitter>
<Blacksmoke16> @silmanduin66 make sure your db creds are correct?
<FromGitter>
<silmanduin66> i solved it . I forgot to change the url database because on heroku it has an other adress. Also i had to manually create the databases