sails-migrations icon indicating copy to clipboard operation
sails-migrations copied to clipboard

Auto-generate migrations for models

Open kevinob11 opened this issue 10 years ago • 2 comments

A new feature that I think might be useful for sails migrations:

The ability to auto-generate a migration based on a model file. It wouldn't consistently auto-generate migrations for changes, as this seems like it would be difficult and require managing state. The thought is more of a one-time per model time saver. You define your model then call: sails-migrations generate:model [name of model] It then parses the model file and creates a migration file based on that model. It doesn't have to parse everything in attributes, if there is some non-standard or in-depth attribute we can just rely on the user updating the migration file to handle that attribute. In my mind the low hanging fruit are:

  • Table Names
  • Column Names
  • Types
  • Required (though waterline ignores this in auto-migrations, so maybe we should too)
  • Unique
  • Simple relations (make them integers)
  • More complex relations (Too difficult without having context on both models?)

I'm happy to take a hack at it, but it will just be weekend time which itself is a bit limited right now for me.

kevinob11 avatar Feb 26 '15 16:02 kevinob11

Hmm, sounds really cool, And not that hard, no actual parsing is probably needed since we actually load sails, so you can access all the models easily.

I've no idea when i'll have some free time to work at it.. a lot on my plate right now.

BlueHotDog avatar Feb 26 '15 17:02 BlueHotDog

Still open for PRs though :D

RWOverdijk avatar Jan 14 '16 09:01 RWOverdijk