0
votes

Is there a way to get silverstripe to generate Dataobjects from an existing schema? Sort of the reverse to /dev/build

I have an existing project which I want to migrate to Silverstripe, unfortunately this means creating Dataobject classes for 30+ tables.

Either no one has ever done this or my google foo is not that good?

Being a dev, Im sure I could automate this myself but I'm debating if it will be any quicker than just creating them manually?

1
I don't know a module which will do that for you, but it should be feasible, at least for simple properties: Get the column name from the schema and set the right data type. It's definitely more complicated with foreign keys, especially m:n, but it should be doable as well. However, unless you'll need this kind of feature on a regular basis, I don't think the effort required will pay off - xeraa
Thanks for your comment... Bugger, I was hoping someone knew of a module in existence. Indeed, I will have to weigh up if the effort is worth it before implementing one myself. - CJSewell

1 Answers

0
votes

I don't think there's actually a way to do what you want, and I'm not sure it's technically feasable. Anyway there's SilverSmith module that can help you in this task, it can generate code from a YAML file: https://github.com/unclecheese/SilverSmith