Comments (6)
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.
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.
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 ownIColumnsConvention
the the set - A custom
IConventionSet
as scoped service, which should be derived fromDefaultConventionSet
, have only one public constructor, and the customIColumnsConvention
must be added to theColumnsConventions
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.
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.
Duplicate of #1032
from fluentmigrator.
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)
- Get rid of Microsoft.NETCore.App 2.1 dependency on dotnet-fm HOT 5
- Why FluentMigrator v5.1.0 is not visible on nuget.org? HOT 1
- Breaking changes in migration runner between 3.3.2 and 5.0.0 HOT 3
- fluentmigrator is missing NuGet package README file
- Sqlite AutoIncrement with other primary keys broken in 5.x HOT 9
- Publish option PublishSingleFile=true breaks fluent migrator rollout HOT 2
- Create index with include columns dont work HOT 12
- Table rename in custom schema HOT 3
- Can no longer create primary key on SQLite with FluentMigrator 5 HOT 2
- Update dependabot.yaml to support grouped updates HOT 5
- Tests failing on M1 Mac due to newline character comparison
- Remove obsolete property GenericGenerator.compatabilityMode HOT 1
- Still no migrations found using the fm tool. HOT 1
- How to determine the current runner default schema from within a migration? HOT 11
- GitHub AzureDevOps Pipeline Branch Filters no longer triggering CI builds
- SQLite FluentMigrator InSchema Error HOT 6
- Remove Obsolete ApplicationContext
- How to get rid of "Description:" in every column description? HOT 1
- Can no longer create foreign key on SQLite with FluentMigrator.Runner 5.2.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentmigrator.