Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 24 posts 69 karma points
    Dec 16, 2014 @ 16:34
    Tom
    1

    We've OS'd and Nuget'd our in house Fluent Api and Migration framework

    Hi guys, just in case anybody else might benefit from it we have finally been given the green light to release our in house Fluent Api and Migration framework.

    First a little background. About 18 months ago a team was put together to move all our organisations websites to a single platform, Umbraco. We are all from agile backgrounds and most of us have worked together in the past, but non of us had touched Umbraco before.

    Our brief was to do it agile, in the cloud and auto scaling. Needless to say Umbraco doesn't lend itself to Agile practices like CI, large flexing dev teams or auto scaling without some work. We tried the existing packages available to help us achieve these goals with little success so worked on our own fluent migration style deployment mechanism. Which allows us to write code like below and have it automatically executed safely.

    public override void Migrate()
        {
            var basePageDt = DocumentType.Get("BasePage");
    
            var zoneHomepageTemplate = Template.Create("zoneHomepage", "Zone Homepage");
    
            var zoneHomepageDt = DocumentType.Create("zoneHomepage", "Zone Homepage")
                                             .SetParent(basePageDt)
                                             .AddAllowedTemplate(zoneHomepageTemplate)
                                             .SetDefaultTemplate(zoneHomepageTemplate)
                                             .Save();
    
            zoneHomepageDt
                .CreateTab("Content")
                .AddProperty("image", "Image", DataTypes.MediaPicker, "Content", false, "Image Description")
                .AddProperty("header", "Header", DataTypes.TextString, "Content", false, "Header Description")
                .AddProperty("richtext", "Wysiwyg Content", DataTypes.RichtextEditor, "Content", false, "WYSIWYG content description")
                .AddProperty("callToAction", "Call To Action", CustomDataTypeConsts.UrlPicker, "Content", false)
                .AddProperty("widgets", "Widgets", CustomDataTypeConsts.WidgetPicker, "Content", false, "Widgets to display below text area")
                .Save();
         }
    

    We've been using it for the last 9 months to deploy changes all the way to production, there are currently 219 migrations at time of writing and to date have had no issues (touch wood).

    It still needs work, and although we have put some effort into making it usable for others its development is on going.

    GitHub : https://github.com/dev-mag/uFluent

    There is a umbraco project for it bit it just serves as a link to Github, Nuget packages and a place for discussion. http://our.umbraco.org/projects/developer-tools/ufluentmigrate

  • Andrey Shchekin 8 posts 71 karma points c-trib
    Dec 18, 2014 @ 22:58
    Andrey Shchekin
    0

    That's cool. Just FYI we also did a similar thing recently:
    https://github.com/AffinityID/uMigrate

    public class Migration_201409261039_First : UmbracoMigrationBase {
        public override void Run() {
            var dataType = DataTypes.Add("NewDataType", Constants.PropertyEditors.Textbox);
            ContentTypes.Add("NewDocumentType").AddProperty("NewProperty", dataType.Object);
        }
    }
    
    public class Migration_201412151705_CorrectSomeDataTypes : UmbracoMigrationBase {
        protected override void Run() {
            DataTypes
                .WhereEditorAliasIs("SomeEditor")
                .ChangeAllPropertyValues((string v) => v + "_corrected")
                .SetPreValue("correct", "true");
        }
    }
    

    Though our API might be a bit less stable/still evolving.

  • Tom 24 posts 69 karma points
    Dec 19, 2014 @ 12:09
    Tom
    0

    Ye we seen that, by the time yours arrived we had already using ours in production for a while so stuck with it. We had coincidentally named ours uMigrate too originally but changed it so there could be no confusion now its in the wild.

  • Andrey Shchekin 8 posts 71 karma points c-trib
    Dec 21, 2014 @ 22:14
    Andrey Shchekin
    0

    Sounds reasonable. Thanks for changing the name!

Please Sign in or register to post replies

Write your reply to:

Draft