sails-migrations
sails-migrations copied to clipboard
Auto-generate migrations for models
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.