forked from fluentmigrator/fluentmigrator
-
Notifications
You must be signed in to change notification settings - Fork 1
Migration Runners
daniellee edited this page May 9, 2011
·
15 revisions
There are multiple different ways to execute migrations using the runners. The simplest and most straight forward is from the command line using the migrate.exe tool.
For a full listing of options simply run migrate.exe from the command line by itself.
Migrate.exe /connection "Data Source=db\db.sqlite;Version=3;" /db sqlite /target your.migrations.dll
<?xml version="1.0" encoding="UTF-8" ?>
<project name="fluentmigrator" xmlns="http://nant.sf.net/release/0.85/nant.xsd" default="migrate">
<loadtasks assembly="../../build/FluentMigrator.NAnt.dll" />
<target name="migrate" description="Migrate the database to the latest version">
<migrate
database="sqlite"
connection="Data Source=:memory:;Version=3;New=True;"
namespace="FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass3"
target="../../build/FluentMigrator.Tests.dll"
/>
</target>
<target name="migrate-rollback" description="Migrate the database back one version">
<migrate
database="sqlite"
connection="Data Source=:memory:;Version=3;New=True;"
namespace="FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass3"
target="../../build/FluentMigrator.Tests.dll"
task="rollback"
/>
</target>
<target name="migrate-rollback-all" description="Migrates the database back to original state prior to applying migrations">
<migrate
database="sqlite"
connection="Data Source=:memory:;Version=3;New=True;"
namespace="FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass3"
target="../../build/FluentMigrator.Tests.dll"
task="rollback:all"
/>
</target>
</project>
<?xml version="1.0"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Migrate">
<PropertyGroup>
<MigratorTasksPath>../../build</MigratorTasksPath>
</PropertyGroup>
<UsingTask TaskName="FluentMigrator.MSBuild.Migrate"
AssemblyFile="../../build/FluentMigrator.MSBuild.dll"/>
<Target Name="Migrate" >
<Message Text="Starting FluentMigrator Migration"/>
<!-- The dll must be located where dotnet assembly loader can find it (same folder as the fluentmigrator dlls) -->
<Copy SourceFiles="./build/FluentMigrator.Example.dll" DestinationFolder="$(MigratorTasksPath)"/>
<!-- Important: Target must be your Migrations assembly name, not your dll file name. -->
<Migrate Database="postgres"
Connection="Server=127.0.0.1;Port=5432;Database=FluentMigrator;User Id=test;Password=test;"
Target="FluentMigrator.Example">
</Migrate>
</Target>
<Target Name="MigrateRollback" >
<Message Text="Starting FluentMigrator Migration Rollback"/>
<!-- The dll must be located where dotnet assembly loader can find it (same folder as the fluentmigrator dlls) -->
<Copy SourceFiles="./build/FluentMigrator.Example.dll" DestinationFolder="$(MigratorTasksPath)"/>
<!-- Important: Target must be your Migrations assembly name, not your dll file name. -->
<Migrate Database="postgres"
Connection="Server=127.0.0.1;Port=5432;Database=FluentMigrator;User Id=test;Password=test;"
Target="FluentMigrator.Example"
Task="rollback">
</Migrate>
</Target>
<Target Name="MigrateRollbackAll" >
<Message Text="Starting FluentMigrator Migration Rollback All"/>
<!-- The dll must be located where dotnet assembly loader can find it (same folder as the fluentmigrator dlls) -->
<Copy SourceFiles="./build/FluentMigrator.Example.dll" DestinationFolder="$(MigratorTasksPath)"/>
<!-- Important: Target must be your Migrations assembly name, not your dll file name. -->
<Migrate Database="postgres"
Connection="Server=127.0.0.1;Port=5432;Database=FluentMigrator;User Id=test;Password=test;"
Target="FluentMigrator.Example"
Task="rollback:all">
</Migrate>
</Target>
</Project>
- Getting FluentMigrator
- How to create a Migration
- Fluent Interface
- Migration Runners
- Use inbuilt database functions when setting the default value
- Sql Server Specific Extensions
- Raw Sql Helper for inserting data
- Auto Reversing Migrations
- Resharper File Template
- Transaction Modes for the Migration Runner
- ApplicationContext: Passing parameters to Migrations
- Dealing with Multiple Database Types
- Filter migrations run based on Tags
- Enforce migration version numbering rules
- Create custom metadata for the VersionInfo table