damln/localtower

Suggested Feature: Add_References

Closed this issue · 1 comments

For migrations, it would be great if you could add a “add_references” type of migration that generates migration similar to the terminal command "rails g migration AddAccountToUsers account:references"

Currently the only way to add references for a belongs_to relationship is "add_column"
screen shot 2017-03-09 at 9 47 52 pm

Problem:
The problem with this is that novice users might make mistakes in the naming of the column. Example: naming it "account" vs "account_id", which can lead to the reference being applied inappropriately.

Solution:
A simple solution would be to add a "add_references" action for the migration creations. Then in the "COLUMN" section of the form, have the user pick the "target table" for which the model belongs to (Example:
Action: Add_references,
Model: User,
Column: Account)

Then when submitting it, have the following type of migration generate:
screen shot 2017-03-09 at 9 48 15 pm

damln commented

Implemented in 0.1.4 ;)