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>
<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>
<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