Home:ALL Converter>Create a sequence in Oracle with fluentmigrator

Create a sequence in Oracle with fluentmigrator

Ask Time:2012-07-05T17:35:34         Author:Julius

Json Formatter

I'm new to FluentMigrator and Oracle. We are trying to support MsSql server, Postgres and Oracle in our migration scripts.

Since NHibernate uses sequence in Oracle and identity in the two other, we need to add a sequence;

public class CreateTagSystem : Migration
{
    public override void Up()
    {
        IfDatabase("MsSql2008", "Postgres").Create.Table("TestTable").WithColumn("Id").AsInt16().PrimaryKey().Identity();

        IfDatabase("Oracle").Create.Table("TestTable").WithColumn("Id").AsInt16().PrimaryKey();

        IfDatabase("Oracle").Create.Sequence("hibernate_sequence");
    }

    public override void Down()
    {
        Delete.Table("TestTable");
    }
}

This results in;

System.NullReferenceException : Object reference not set to an instance of an object.
at FluentMigrator.Runner.Generators.Generic.GenericQuoter.IsQuoted(String name) in D:\Development\Code\GitHub\fluentmigrator\src\FluentMigrator.Runner\Generators\Generic\GenericQuoter.cs: line 105
at FluentMigrator.Runner.Generators.Generic.GenericQuoter.QuoteSchemaName(String schemaName) in D:\Development\Code\GitHub\fluentmigrator\src\FluentMigrator.Runner\Generators\Generic\GenericQuoter.cs: line 183
at FluentMigrator.Runner.Generators.Generic.GenericGenerator.Generate(CreateSequenceExpression expression) in D:\Development\Code\GitHub\fluentmigrator\src\FluentMigrator.Runner\Generators\Generic\GenericGenerator.cs: line 360
at FluentMigrator.Runner.Processors.ProcessorBase.Process(CreateSequenceExpression expression) in ProcessorBase.cs: line 138
at FluentMigrator.Expressions.CreateSequenceExpression.ExecuteWith(IMigrationProcessor processor) in D:\Development\Code\GitHub\fluentmigrator\src\FluentMigrator\Expressions\CreateSequenceExpression.cs: line 17
at FluentMigrator.Runner.MigrationRunner.<>c__DisplayClasse.<ExecuteExpressions>b__b() in MigrationRunner.cs: line 349
at FluentMigrator.Runner.MigrationRunner.AnnounceTime(String message, Action action) in MigrationRunner.cs: line 379
at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions) in MigrationRunner.cs: line 362
at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration) in MigrationRunner.cs: line 304
at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(Int64 version) in MigrationRunner.cs: line 189
at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement) in MigrationRunner.cs: line 96  

Looking at the source I need a schema (see GenericGenerator.cs line 360)? But what is the schema in this context?

Author:Julius,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11341606/create-a-sequence-in-oracle-with-fluentmigrator
yy