Copied to clipboard

Flag this post as spam?

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


  • Jonathan Bäckström 6 posts 96 karma points
    Sep 04, 2018 @ 14:25
    Jonathan Bäckström
    0

    Ability to create column as text with migrations

    Hi,

    I have a suggestion for an upgrade of umbraco migrations which can be used to create custom database tables. I don't know where to post a suggestion like this so if there is a better place, please let me know!

    When using umbraco migrations to create custom database tables, I would like to have the option to create a column with datatype NTEXT instead of just using NVARCHAR (as from AsString()). This to allow longer text to be stored than maximum length of NVARCHAR which is 4000 characters.

    So you can use:

    Create.Table(tableName)
                .WithColumn("text").AsText()
    

    instead of:

    Create.Table(tableName)
                .WithColumn("text").AsString(4000)
    
  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Sep 04, 2018 @ 14:56
    Kevin Jump
    101

    Hi Jonathan,

    I think you can - although it's not straight forward.

    using the AsCustom option

    this bit of code is from one of the Migrations inside umbraco and it creates a NTEXT column.

    var textType = SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT);
    Create.Column("tourData").OnTable("umbracoUser").AsCustom(textType).Nullable();
    

    Although an AsNTEXT() would be nice :) - you could log an issue in github ? ( https://github.com/umbraco/Umbraco-CMS/issues ) and its probibly not a big change in terms of code as its just one more function in this file ... https://github.com/umbraco/Umbraco-CMS/blob/1bb593d264a085f94a3ce3bd710392b350561430/src/Umbraco.Core/Persistence/Migrations/Syntax/ExpressionBuilder.cs#L142

    Kevin

  • Jonathan Bäckström 6 posts 96 karma points
    Sep 04, 2018 @ 15:03
    Jonathan Bäckström
    0

    Thank you!

    I was looking for some kind of work around but never thought of the custom type. I can log an issue on github.

    Thank again!

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Sep 04, 2018 @ 15:11
    Kevin Jump
    0

    yeah, thinking about it - it might exist this way on purpose,

    in the code above the SQLSyntax line gets NTEXT for the database type you are running on (SqlServer, SqlExpress or mySql) it might be that it's diffrent depending on the platform, and that's why its not in the core as its own function ?

    Kevin

Please Sign in or register to post replies

Write your reply to:

Draft