-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use schema.cr instead of mappings? #11
Comments
@watzon really interesting thought but it needs to make database structure analyzer. Will take a look when will got free time |
problem could be with allowing manual overriding fields under the model as well |
In case you would be looking into this, I would suggest to keep the model related code to models and extract the mapping using modules for those who feel clutter if there is any way, class User < Jennifer::Model::Base
include UserMapping
end
module UserMapping
mapping(
id: { type: Int32, primary: true }
)
end I see this as a cosmetic change rather than an improvement at this stage. |
@thomasnal I think you misunderstand the direction of the issue. The proposal is to have Jennifer analyze the database itself and build the mapping for you, such that you don't need to do (similar to Ruby's |
Haven't seen it described above this way. Any idea how to get mapping automatically for free, having it inferred from migrations and database is welcome for the future. I see quite a number of other practical hurdles than to be concerned about this one at the moment. |
@z64 is right - this one is more about automatic schema generation. I have idea how to do this but for now there are a lot of important things to fix. So this will be added not as soon as I thought previously |
I'm glad that this has at least been getting some attention. @z64 is right, but I understand that this isn't exactly top priority. It would definitely be a "nice to have" though. |
Yeah. I keep this in mind and try make all new staff easy to migrate to this approach later, but for now main point is to make Jennifer useful and working tool for production purposes. |
Hey, just wanted to touch base and see if any progress was made on this front in the last 2 years. I just started using Jennifer with Amber. |
Hi. For that period of time this feature had low priority. The reason is that model declaration is inside of a model, so all fields and their types are inside of related file; database structure can be quickly loaded from |
Completely Understand. Glad to hear it'll be coming sometime in the future and wasn't totally benched. Love your orm. Thanks! |
+1 It would be awesome to have this feature, this is something I love in ActiveRecord (from Rails), it maintains a schema.rb always up to date. |
This a more of a question/request, but have you considered using a
schema.cr
file instead of amapping
macro inside of the model? I realize it would be a big change, but it would bring an important benefit, the ability to have the model definition update automatically. It also makes the model files look a little less cluttered.Obviously, the one downside to this is that you don't have everything to do with the model all in one place, but I feel like it would be an ok tradeoff.
Thoughts?
The text was updated successfully, but these errors were encountered: