Giter Site home page Giter Site logo

Comments (6)

fubar-coder avatar fubar-coder commented on May 26, 2024

This is what I did when I needed to support a "JSON" column, but it should be usable for your situation too: I created a custom IColumnsConvention.

Example:

class MyCustomColumnConvention : IColumnsConvention {
  private readonly string _databaseType;

  public MyCustomColumnConvention(IProcessorAccessor processorAccessor) {
    _databaseType = processorAccessor.Processor.DatabaseType.ToLowerInvariant();
  }

  public IColumnsExpression Apply(IColumnsExpression expression) {
    var jsonColumns = expression.Columns
      .Where(x => string.Equals("json", x.CustomType, StringComparison.OrdinalIgnoreCase))
      .ToList();
    if (jsonColumns.Count == 0) {
      return expression;
    }

    if (_databaseType == "sqlserver2016") {
      foreach (var column in jsonColumns) {
        column.CustomType = null;
        column.Type = DbType.String;
        column.Size = int.MaxValue;
      }
    }

    return expression;
  }
}

from fluentmigrator.

schambers avatar schambers commented on May 26, 2024

Do you think your comment would be useful in the documentation @fubar-coder? I can create an issue to add this example there. This is a good work around it seems.

from fluentmigrator.

fubar-coder avatar fubar-coder commented on May 26, 2024

Yes, it might be a good idea, but a full example is needed to be a usable example, which requires either:

  • Querying the scoped IConventionSet service and add your own IColumnsConvention the the set
  • A custom IConventionSet as scoped service, which should be derived from DefaultConventionSet, have only one public constructor, and the custom IColumnsConvention must be added to the ColumnsConventions property

The first one works better when the developer relies on behavior of the IConventionSetAccessor implementation (AssemblySourceConventionSetAccessor), while the second is better if you prefer not to rely on assembly scanning.

from fluentmigrator.

schambers avatar schambers commented on May 26, 2024

How does this look @fubar-coder, I'm unsure of option 2 and was contemplating leaving it as it appears but open to suggestions: fluentmigrator/documentation@7082a13

from fluentmigrator.

jzabroski avatar jzabroski commented on May 26, 2024

Duplicate of #1032

from fluentmigrator.

schambers avatar schambers commented on May 26, 2024

I'll close this as I have an issue on the documentation repo to cover this documnetation: fluentmigrator/documentation#75

We could move any discussion there

from fluentmigrator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.