caslu
Mix phx.gen: Add not-null modifier to Phoenix generators
Recently (last week) this PR was merged in Ruby on Rails repository and i thought it could be nice to have in phoenix, basically what it does is to add a “!” operator at the end of each type, so in summary we would type:
$ mix phx.gen.schema Blog.Post blog_posts title:string! views:integer!
and the current output would be generated:
defmodule MyApp.Repo.Migrations.CreateBlogPosts do
use Ecto.Migration
def change do
create table(:blog_posts) do
add :title, :string, null: false
add :views, :integer, null: false
timestamps(type: :utc_datetime)
end
end
end
If you think this make sense as i do and like the idea i think would be great for me to work in this feature since i’m always looking to ways to contribute with code for phoenix, but i would need some help and i’d be really greateful if you guys could help me do it.
IMPORTANT: There’s my first feature suggestion and i don’t know very well how things are done here, sorry if the post does not follow any standard or something like that.
Most Liked
rhcarvalho
It’s a reasonable feature. I occasionally add null: false after generating migrations.
Let’s hear what other people think.
If you have buy-in from the Phoenix team I can help you both suggesting pointers for where to look at in the code base as well a reviewing a PR.
dimitarvp
I do like the idea and I believe I’ve seen it in other ecosystems as well. But there must always be kept a balance between over-loading a DSL and the usefulness that the new feature will bring. It’s not a clear win in favor of adding the bang variant.
rhcarvalho
(If your driving motivation is to contribute something, and you are interested in the code generators, this open issue might serve as a good entrypoint to the topic Calling phx.mix.gen without specifying attributes will succeed but create broken code · Issue #5870 · phoenixframework/phoenix · GitHub)
Popular in Proposals: Ideas
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








