caslu

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

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

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

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)

Where Next?

Popular in Proposals: Ideas Top

Jskalc
Hi everyone! Recently I was thinking a lot about the way HEEX renders lists. People are generally surprised about huge payloads being sen...
New
andypearson
Hey all, I have been working on some performance improvements for the Phoenix application I work on. As part of this, through trial and...
New
lessless
Hi, There are a few writeups describing alternative config arrangements by a topic (or an OTP app): Configuring Phoenix apps: Two sma...
New
cheerfulstoic
I feel like Elixir is getting big enough and old enough that I’m starting to experience problems with conflicting dependencies. An examp...
New
bartblast
This could resolve to {[a: 1, b: 2]}. Was it ever considered to allow such syntax? Notice this: {:abc, a: 1, b: 2} and this: my_fun(:abc,...
New
Astolfo
When generating a release with phx.gen.release --docker a debian version is used by default to avoid “DNS issues” on Alpine. It seems li...
New
BartOtten
I’d like to propose that we refrain from using the term "DeadView" as the opposite of “LiveView” and instead choose an alternative. A new...
New
mortenlund
Hi! Suggest to add the ability to do use the components socket as input into Phoenix.LiveView.send_update/3 function to make it easier t...
New
dimitarvp
To @jonatanklosko and @the-mikedavis: I see that there is a Rust crate at crates.io: Rust Package Registry but it is pointing at https:/...
New
dibok
Hi, I’m trying to use phoenix.js in my Qt QML project which has it’s own buildin JavaScript engine. Problem is that (what I googled so f...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement