faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
yashko has joined #amber
<yashko> hi guys! Is there anyone?
yashko has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Yashko> So basically i've created a model via cli. Afterwards i inserted one more column (right in the model file). How to update database now?
<FromGitter> <Blacksmoke16> prob generate another migration and run it
<FromGitter> <Yashko> Doesn't work
<FromGitter> <Yashko> i tried `amber generate user`, then "keep all", and the migration contains only default fields (id and timestamps)
<FromGitter> <Blacksmoke16> that would generate a user model afaik
<FromGitter> <Blacksmoke16> i think you want like `amber g migration`
<FromGitter> <Blacksmoke16> or something like that
<FromGitter> <Yashko> @Blacksmoke16 Right, this will create an empty migration. How can i add my model inside of it?
<FromGitter> <Blacksmoke16> is there another migration you can reference?
<FromGitter> <Blacksmoke16> one would have been made for the initial state of your users table no?
<FromGitter> <Yashko> Like how? I have one migration (which was created right after i ran `amber g model user`)
<FromGitter> <Yashko> And one empty migration from `amber g migration`
<FromGitter> <Blacksmoke16> what does the first migration look like?
<FromGitter> <Yashko> ``````
<FromGitter> <Blacksmoke16> im assuming its like
<FromGitter> <Yashko> -- +micrate Up ⏎ CREATE TABLE users ( ⏎ id BIGSERIAL PRIMARY KEY, ⏎ created_at TIMESTAMP, ⏎ updated_at TIMESTAMP ... [https://gitter.im/amberframework/amber?at=5e7ea26359057617f0480dd2]
<FromGitter> <Blacksmoke16> right
<FromGitter> <Blacksmoke16> so just add the SQL to add your new column?
<FromGitter> <Blacksmoke16> or if you're still developing, alter the original until you get it in a good state then can down/up it
<FromGitter> <Yashko> Yes, i can do it. But it will be manually. I'm looking into whether amber have ability to do it automatically
<FromGitter> <Blacksmoke16> automatically based on the model definition?
<FromGitter> <Yashko> Right!
<FromGitter> <Blacksmoke16> i would doubt it
<FromGitter> <Blacksmoke16> idt any framework has that feature
<FromGitter> <Blacksmoke16> (in crystal)
<FromGitter> <Yashko> I mean it would be awesome if i will run lets say `amber g model user`, then make some adjustments to the `models/user.cr` and run `amber g model user` > `keep all` and it will create a migration based on the new model
<FromGitter> <Blacksmoke16> hmm yea idk, would have to run that past others
<FromGitter> <Yashko> why?
<FromGitter> <Yashko> in case if you can afford just drop the old schema. Guess i will go and take a look at source, it doesn't sound like a complex matter
<FromGitter> <Yashko> Because currently if developer need 10+ or even more columns it will be kinda unconvient to pass all of them to the `amber g model user age:int` etc
<FromGitter> <Blacksmoke16> because im not really involved in Amber core development
<FromGitter> <Blacksmoke16> others are more familiar might have thoughts/suggestions
<FromGitter> <Yashko> Me neither, just found it by accident
<FromGitter> <Yashko> Anyway thank you! <3
<FromGitter> <Blacksmoke16> np
<FromGitter> <Yashko> And so far as I can tell it's the best option for building robust applications on Crystal
<FromGitter> <Yashko> btw do you know is this?
<FromGitter> <Yashko> `<<-DEPENDENCY ⏎ ⏎ ``` require "../src/models/**" ⏎ DEPENDENCY```` [https://gitter.im/amberframework/amber?at=5e7ea41db407e11e3cbc1fc5]
<FromGitter> <Yashko> `<<-` this operator
<FromGitter> <Yashko> How it supposed to work? https://play.crystal-lang.org/#/r/8s7s
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8s7t
<FromGitter> <Blacksmoke16> it just a fancy syntax for making multi line strings
<FromGitter> <Yashko> Interesting
<FromGitter> <Blacksmoke16> Right, it's just a string
<FromGitter> <Yashko> Any luck with crystal debug inside VS Code anyone?
<FromGitter> <damianham> @Yashko at the moment there is no option to automatically modify database tables based on model fields, so (post public release) you need to create a migration to modify the table and add the column. As @Blacksmoke16 points out, prior to public release you should simply modify the migration that creates the table. It is almost an anti-pattern to create new table altering migrations prior to the first public release.
<FromGitter> <drujensen> @Yashko At one point, I attempted to do what you are suggesting but it was clear this wouldn’t work. You need to support migrating from one column to another and there is no way of predicting what the developer intended to do. I tried an additive only approach but you would still need to go back and remove columns so it would require a two step process. Migrations are better in that they run in order and the
<FromGitter> ... database keeps track of what migration you are on so a database can be in any state and the migrations will run from that point forward.
<FromGitter> <drujensen> However, It’s not as dry.
<FromGitter> <JadeKharats> Hello! where to find the list of type for amber g model|scaffold? Example : amber g scaffold Event description:text date:datetime user:reference
<FromGitter> <Yashko> @JadeKharats Check out `amber-stable/src/amber/cli/generators/field.cr`, i think its there
<FromGitter> <JadeKharats> @Yashko Thanks
<FromGitter> <JadeKharats> another newbie question : How to test a controller when i put him in `routes :auth`
<FromGitter> <JadeKharats> i suppose i should modify this block ⏎ ` ⏎ class EventControllerTest < GarnetSpec::Controller::Test ⏎ getter handler : Amber::Pipe::Pipeline ⏎ ... [https://gitter.im/amberframework/amber?at=5e7fbf08d7d8504dee71e9fc]
<FromGitter> <JadeKharats> but i don't know how?