fluent-migrator

Rollback to a specfic Migration in FluentMigrator

空扰寡人 提交于 2019-12-20 06:51:20
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

Rollback to a specfic Migration in FluentMigrator

江枫思渺然 提交于 2019-12-20 06:50:46
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

FluentMigrator Failed Migrations Don't Rollback?

南笙酒味 提交于 2019-12-12 20:57:16
问题 I just began experimenting with FluentMigrator. I noticed that failed migrations are not being rolled back. Has this just not been implemented yet? This seems rather bad because it leaves the database in a broken state. For example, the migration below will obviously fail when it tries to add Table1 for a second time (I'm just doing this to force an error). I would expect the migration to be contained in a transaction which would then be rolled back when it fails. [Migration(1)] public class

Rolling back to previous version in Fluent Migrator

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 02:27:06
问题 I am attempting to get migrations working with my project using fluent migrator. But due to the lack of documentation I am struggling to figure out how to rollback and have the Down method called for my migration class. I set up the db with an initial version 1 class: [Migration(1)] public class Baseline : Migration { public override void Up() { Execute.Script("1_Baseline\\baseline.sql"); } public override void Down() { } } I am running migrations via a batch file containing the following: ".

Update row data with a new value per row using fluentmigrator

折月煮酒 提交于 2019-12-05 07:56:25
I am using fluentmigrator to add a new column to a table. I then want to update each row in the table with a unique value for that column. Currently when I use: Update.Table("Foo").InSchema("dbo").Set(new { Bar = Bar.Generate() }).AllRows(); It gives the same value for all the rows. How do I ensure it calls that method for each row? Daniel Lee I'm not sure what Bar.Generate does but I am guessing it creates a GUID or unique id. If so then you could use: Execute.Sql("update dbo.Foo set Bar = NEWID()"); Or if you want sequential guids then you could use NEWSEQUENTIALID() . If you are adding a

Can I create a column of nvarchar(MAX) using FluentMigrator?

谁都会走 提交于 2019-12-04 14:55:34
问题 Using FluentMigrator, the default creation of a Column using .AsString() results in an nvarchar(255) . Is there a simple way (before I modify the FluentMigrator code) to create a column of type nvarchar(MAX) ? 回答1: You could create an extension method to wrap .AsString(Int32.MaxValue) within .AsMaxString() e.g. internal static class MigratorExtensions { public static ICreateTableColumnOptionOrWithColumnSyntax AsMaxString(this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax) {

Can I create a column of nvarchar(MAX) using FluentMigrator?

若如初见. 提交于 2019-12-03 09:17:51
Using FluentMigrator , the default creation of a Column using .AsString() results in an nvarchar(255) . Is there a simple way (before I modify the FluentMigrator code) to create a column of type nvarchar(MAX) ? You could create an extension method to wrap .AsString(Int32.MaxValue) within .AsMaxString() e.g. internal static class MigratorExtensions { public static ICreateTableColumnOptionOrWithColumnSyntax AsMaxString(this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax) { return createTableColumnAsTypeSyntax.AsString(int.MaxValue); } } OK, I found it. Basically, use .AsString

Is it possible to use fluent migrator in application_start?

隐身守侯 提交于 2019-12-02 16:43:00
I'm using fluent migrator to manage my database migrations, but what I'd like to do is have the migrations run at app start. The closest I have managed is this: public static void MigrateToLatest(string connectionString) { using (var announcer = new TextWriterAnnouncer(Console.Out) { ShowElapsedTime = true, ShowSql = true }) { var assembly = typeof(Runner).Assembly.GetName().Name; var migrationContext = new RunnerContext(announcer) { Connection = connectionString, Database = "SqlServer2008", Target = assembly }; var executor = new TaskExecutor(migrationContext); executor.Execute(); } } I'm