Why can't I set null and default for migrations via the commandline?

Seems like a very essential thing. Doesn’t feel right having to manually add them in afterwards.

Maybe someone here knows someone on the Rails core team and can forward this to them?

Cheerio!

I think there was an issue or maybe even a PR recently that tried to introduce defaults for the command line generators. Could you try searching for it?

I think it’s this discussion Feature request: Ability to set default values with `rails generate` - #2 by hahmed

1 Like

@SkinnyPete could you consider closing one of the issues?

Happy to carry on the discussion here if you like…

I wonder if the issue is that it’s unclear how to add this feature without affecting the existing interface?

I wonder if we could update what’s passed to the modifier?

Before

rails generate model post title:string{40}:index

After

rails generate model post title:string{40, null: false, default: ""}:index
1 Like

There’s a PR for this:

2 Likes