lapis
lapis copied to clipboard
Automatically add foreign key constraints
It would be awesome if when using a type foreign_key
, Lapis could automatically create a new foreign key constraint in the DB.
The would mean Lapis would need to allow type.foreign_key
to accept some new arguments, like { table = 'users' }
in order to know what the referenced table should be. However, a default could work such that any column of the form {other_model}_id
would use that table, à la Rails and other ORMs.
However, it is worth noting that adding "FOREIGN KEY (user_id) REFERENCES users"
(for example) to the create_table
call accomplishes the same result. So it's not a huge deal. :)