Cassandra.Fluent.Migrator
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Cassandra.Fluent.Migrator --version 1.0.0
NuGet\Install-Package Cassandra.Fluent.Migrator -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cassandra.Fluent.Migrator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cassandra.Fluent.Migrator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cassandra.Fluent.Migrator, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cassandra.Fluent.Migrator as a Cake Addin #addin nuget:?package=Cassandra.Fluent.Migrator&version=1.0.0 // Install Cassandra.Fluent.Migrator as a Cake Tool #tool nuget:?package=Cassandra.Fluent.Migrator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Cassandra Fluent Migrator
Cassandra Fluent Migrator is a library that offers a set of fluent code and extensions to facilitate the creation and management of the migrations using code instead of CQL commands.
Stack
- NetCore 3.1 LTS
- Cassandra CSharp driver - v3.15: A modern, feature-rich and highly tunable C# client library for Apache Cassandra using Cassandra’s binary protocol and Cassandra Query Language v3.
Installation
PM> Install-Package Cassandra.Fluent.Migrator
Future Improvements
- Add support for more complex types.
- Add support for the
Materialized views
. - Convert the library to
DotNet Standard
.
Documentations
- Wikipage: Full documentation for the library.
- Cassandra Migrator: The core class of the library.
- Cassandra Fluent Migrator: The migration helper class.
- Migrator interface: The base properties and method that the migrations should implement.
- Example: An example on how to use the library.
- Supported Types: List of supported types.
Basic Usage
- Migration class
In your project create a migration class that implements the IMigrator
Interface as follow:
public class InitialMigration: IMigrator
{
private readonly ICassandraFluentMigrator cfm;
private readonly ILogger<InitialMigration> logger;
public InitialMigration(ILogger<InitialMigration> logger, ICassandraFluentMigrator cfm)
{
this.cfm = cfm;
this.logger = logger;
}
public string Name => this.GetType().Name;
public Version Version => new Version(1, 0, 0);
public string Description => "First migration to initialize the Schema";
public async Task ApplyMigrationAsync()
{
this.logger.LogDebug($"Creating the Address User-Defined type...");
await this.cfm.CreateUserDefinedTypeAsync<Address>();
// Should not be here in real-world application.
// Used only for example purposes.
this.cfm
.GetCassandraSession()
.UserDefinedTypes.Define(
UdtMap.For<Address>()
.Map(a => a.Number, "Number".ToLower())
.Map(a => a.Street, "Street".ToLower())
.Map(a => a.City, "City".ToLower())
.Map(a => a.Contry, "Contry".ToLower())
.Map(a => a.Province, "Province".ToLower())
.Map(a => a.PostalCode, "PostalCode".ToLower()));
this.logger.LogDebug($"Creating the User table...");
await this.cfm.GetTable<Users>().CreateIfNotExistsAsync();
}
}
- Startup class
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
// Custom method that you can create to initialize the Cassandra {ISession}.
services.AddCassandraSession(this.Configuration);
// Register the migrations
services.AddTransient<IMigrator, InitialMigration>();
// Required by the library to register the needed classes.
services.AddCassandraFluentMigratorServices();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
// Start the migration process.
app.UseCassandraMigration();
...
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- CassandraCSharpDriver (>= 3.15.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.4)
- Microsoft.Rest.ClientRuntime.Azure.Authentication (>= 2.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.0.0