Fluentmigrator firebird trigger

427 views Asked by At

Is there a way to create a trigger using fluentmigrator / firebirdsql?

When I try this

Execute.Sql(@"CREATE TRIGGER TEST_BI FOR 'Test'
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
    IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GEN_TEST_ID,1)
END
");

nothing happens. I tried the firebird syntax using SET TERM ^; but I get an error then. I also tried calling the DDL statement from a script, with Execute.Script() but still nothing.

Any suggestions? Thanks!

1

There are 1 answers

2
Daniel Lee On

I don't know too much about Firebird but I'm guessing that you cannot create triggers within a transaction. Check out this wiki page about how to turn off transactions: https://github.com/schambers/fluentmigrator/wiki/Transaction-modes-for-the-migration-runner

You need to set an attribute on your migration like this:

[Migration(201304210958, TransactionBehavior.None)]