Git Product home page Git Product logo

rjanisch / migrator.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotnetprojects/migrator.net

0.0 0.0 0.0 53.43 MB

Database migrations for .NET. Based on the idea of Rails ActiveRecord Migrations. This fork aims to improve support for having a single set of migrations applied to 4/5 DB vendors simultaneously (Including addressing issues around data types like Guids, and lots of little tweaks to deal with things like reserved word differences between databases etc.)

ASP 0.20% C# 68.58% XSLT 4.95% Batchfile 0.02% HTML 15.57% PowerShell 0.09% Rich Text Format 10.60%

migrator.net's Introduction

Info

This Project includes most of the changes from all forks on GitHub!

But has also a few changes:

  • SQLite support is better (Schema Reading, multiple Primary Keys, and much more)
  • Remove direct References to the Dataproviders
  • Dump Indexes from SQLServer
  • Different Migration Scopes in one Database

NuGet

https://www.nuget.org/packages/DotNetProjects.Migrator/

Introduction

This project is a fork of "ye olde trusty" Migrator.Net - the original project can be found here on google code, and has since moved to github

Usage Example

M_001_InitialSchema.cs

[Migration(1)]
public class M_001_InitialSchema : Migration
{
	public override void Up()
	{
		Database.AddTable(
			"Users",
			new Column("Id", DbType.Guid, ColumnProperty.NotNull | ColumnProperty.PrimaryKey),
			new Column("CreationDate", DbType.DateTime, ColumnProperty.NotNull),
			new Column("ModificationDate", DbType.DateTime, ColumnProperty.NotNull),
			new Column("Name", DbType.String, 255),
			new Column("Password", DbType.String, 255),
			new Column("ExplicitRoles", DbType.String, int.MaxValue));
	}

	public override void Down()
	{
	}
}

Code to Apply Migration:

using (var p = ProviderFactory.Create(ProviderTypes.SQLite, connection, null))
{
	var migrator = new Migrator(p, typeof(M_001_InitialSchema).Assembly, false));

	if (migrator.LastAppliedMigrationVersion != null && migrator.LastAppliedMigrationVersion.Value > migrator.AssemblyLastMigrationVersion)
	{
		throw new Exception("Database has newer Migrations applied then the Software supports");
	}
	else
	{
		migrator.MigrateToLastVersion();
	}
}

What's different in the fork

In this fork the main changes are:

  • Now targets .Net Framework 4.0 instead of 2.0/3.5.
  • NetStandart 2.0 will be supported when released
  • Support for reserved words.
  • Support for guid types across all databases.
  • Utility classes for removing all tables etc. from a database (to support migration integration tests).
  • Warnings in Oracle when attempting to create column/table/key names that are over-length.
  • Removed reliance on deprecated SqlServer views such as Sysconstraints (to support Azure Sql Server deployment).

migrator.net's People

Contributors

benoitdion avatar bittercoder avatar devmlog avatar eliog avatar geofflane avatar jamesfoster avatar jogibear9988 avatar kayone avatar nhemsley avatar ondrejsv avatar orient-man avatar rjanisch avatar wallymathieu avatar yashikno avatar

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.