Is it possible to create a trigger with FluentMigrator?
Asked Answered
C

2

5

Is it possible to create a trigger with FluentMigrator, without resorting to raw SQL?

I have looked through the object model for the version currently released on Nuget (FluentMigrator.1.0.1.0) and can't see a way of doing it.

Crapulent answered 9/3, 2012 at 12:9 Comment(1)
Did you found a solution for that problem?Almoner
I
5

I'm sure you've figured out by now that the answer is no. And I don't think that triggers will be supported anytime soon. They are very database-specific and would require lots of code to cover all the different cases. See this article on Wikipedia: http://en.wikipedia.org/wiki/Database_trigger

If you really want a Create.Trigger expression in FluentMigrator then pull requests are always welcome!

Instruction answered 13/7, 2012 at 19:42 Comment(0)
T
8

You can use Execute.Script

[Migration(1)]
public class Migration_0001_Baseline : Migration
{

    public override void Up()
    {                        
        Execute.Script("script1.sql");        
    }

    public override void Down()
    {

    }        
}
Taxiplane answered 19/7, 2012 at 14:5 Comment(2)
It's in a file, but it's still "raw SQL."Paintbrush
You'll want a Down script too for Rollback / MigrateDown.Pteropod
I
5

I'm sure you've figured out by now that the answer is no. And I don't think that triggers will be supported anytime soon. They are very database-specific and would require lots of code to cover all the different cases. See this article on Wikipedia: http://en.wikipedia.org/wiki/Database_trigger

If you really want a Create.Trigger expression in FluentMigrator then pull requests are always welcome!

Instruction answered 13/7, 2012 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.