Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parent_id as zero #390

Closed
nolleto opened this issue Dec 1, 2021 · 1 comment
Closed

parent_id as zero #390

nolleto opened this issue Dec 1, 2021 · 1 comment

Comments

@nolleto
Copy link

nolleto commented Dec 1, 2021

Hi, in my current project I'm trying to add this gem and work very well. I just found something annoying that in our parent_id column (that in this project is parent_widget_id) is a required integer

create_table "widgets", id: :serial, force: :cascade do |t|
  t.integer "parent_widget_id", default: 0
  ...
end

So, I was wondering if it is possible to set the root node with 0 value instead of nil?

Just some extra information, this is a really huge project and it's a little hard to find all parent_widget_id logic where is treating the root as 0 then, update the table to convert it to a nullable value to accept nil can lead to some headaches. 😓

@seuros
Copy link
Member

seuros commented Jul 30, 2022

having 0 in the field break database integrity. use foreign keys to avoid having wrong structure.

@seuros seuros closed this as completed Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants