RavenMigrations 3.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RavenMigrations --version 3.0.0
NuGet\Install-Package RavenMigrations -Version 3.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="RavenMigrations" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RavenMigrations --version 3.0.0
#r "nuget: RavenMigrations, 3.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 RavenMigrations as a Cake Addin
#addin nuget:?package=RavenMigrations&version=3.0.0

// Install RavenMigrations as a Cake Tool
#tool nuget:?package=RavenMigrations&version=3.0.0

Raven Migrations

Join the chat at https://gitter.im/migrating-ravens/RavenMigrations

Build status

Quick Start

    PM > Install-Package RavenDB.Migrations

Introduction

Raven Migrations is a migration framework for RavenDB to help with common tasks you might have to do over time to your database. The framework API is heavily influenced by Fluent Migrator.

Philosophy

We believe any changes to your domain should be visible in your code and reflected as such. Changing things "on the fly", can lead to issues, where as migrations can be tested and throughly vetted before being exposed into your production environment. With RavenDB testing migrations is super simple since RavenDB supports in memory databases (our test suite is in memory).

This is important, once a migration is in your production environment, NEVER EVER modify it in your code. Treat a migration like a historical record of changes.

Concepts

Every migration has several elements you need to be aware of. Additionally, there are over arching concepts that will help you structure your project to take advantage of this library.

A Migration

A migration looks like the following:

// #1 - specify the migration number
[Migration(1)]                 
public class First_Migration : Migration // #2 inherit from Migration
{
    // #3 Do the migration
    public override void Up()
    {
        using (var session = DocumentStore.OpenSession())
        {
            session.Store(new TestDocument 
            { 
                Id = "TestDocuments/1",
                Name = "Khalid Abuhakmeh" 
            });
            session.SaveChanges();
        }
    }
    // #4 optional: undo the migration
    public override void Down()
    {
        using (var session = DocumentStore.OpenSession())
        {
            session.Delete("TestDocuments/1");
            session.SaveChanges();
        }
    }
}

To run the migrations, you can use Microsoft's Dependency Injection:

public void ConfigureServices(IServiceCollection services)
{
    // Add the MigrationRunner into the dependency injection container.
    services.AddRavenDbMigrations();

    // ...
   
    // Get the migration runner and execute pending migrations.
    var migrationRunner = services.BuildServiceProvider().GetRequiredService<MigrationRunner>();
    migrationRunner.Run();
}

Not using ASP.NET Core? You can create the runner manually:

// Skip dependency injection and run the migrations.

// Create migration options, using all Migration objects found in the current assembly.
var options = new MigrationOptions();
options.Assemblies.Add(Assembly.GetExecutingAssembly());

// Create a new migration runner. docStore is your RavenDB IDocumentStore. Logger is an ILogger<MigrationRunner>.
var migrationRunner = new MigrationRunner(docStore, options, logger);
migrationRunner.Run();

Full documentation and sample project available on the GitHub repo.

Product 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 netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on RavenMigrations:

Repository Stars
ravendb/samples-yabt
"Yet Another Bug Tracker" solution sample for RavenDB and .NET with Angular UI
Version Downloads Last updated
6.0.1 4,287 1/13/2024
6.0.0 79 1/13/2024
5.0.2 7,303 1/9/2024
5.0.1 184,563 3/21/2022
5.0.0 48,108 7/26/2020
4.3.0 7,933 5/4/2020
4.1.7 27,596 1/21/2019
4.1.6 712 1/18/2019
4.1.4 723 1/4/2019
4.1.3 688 1/3/2019
4.1.2 762 11/27/2018
4.1.1 1,071 10/23/2018
4.1.0 766 10/9/2018
4.0.0 820 9/17/2018
3.0.0 902 7/19/2018
2.1.0 32,083 6/20/2016
2.0.0 2,522 1/22/2016
1.2.0 8,950 5/20/2015
1.1.0 1,039 5/18/2015
1.0.1 1,861 7/10/2014
1.0.0 1,893 10/28/2013

Upgrade to Raven 4, .NET Core 2.1.