Search Results for

    Show / Hide Table of Contents

    Class PostgresExtensions

    Feature extensions for PostgreSQL

    Inheritance
    object
    PostgresExtensions
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: FluentMigrator.Postgres
    Assembly: FluentMigrator.Extensions.Postgres.dll
    Syntax
    public static class PostgresExtensions
    Remarks

    Given: MigrationBase m = null;

    These are valid calls:
    m.Alter.Column("").OnTable("").AsInt16().AddIdentity(PostgresGenerationType.Always);
    m.Alter.Column("").OnTable("").AsInt16().SetIdentity(PostgresGenerationType.Always);
    m.Alter.Column("").OnTable("").AsInt16().DropIdentity(true);
    m.Alter.Column("").OnTable("").AsInt16().Identity();
    m.Alter.Column("").OnTable("").AsInt16().Identity(PostgresGenerationType.Always);  //Ideally would like to stop this, forcing use of AddIdentity instead, but can't
    m.Alter.Table("").AddColumn("").AsInt16().Identity(PostgresGenerationType.Always);
    m.Alter.Table("").AlterColumn("").AsInt16().Identity(PostgresGenerationType.Always);
    
    These are not possible:
    m.Alter.Table("").AddColumn("").AsInt16().AddIdentity(PostgresGenerationType.Always);
    m.Alter.Table("").AddColumn("").AsInt16().SetIdentity(PostgresGenerationType.Always);
    m.Alter.Table("").AddColumn("").AsInt16().DropIdentity(PostgresGenerationType.Always);
    m.Alter.Table("").AlterColumn("").AsInt16().AddIdentity(PostgresGenerationType.Always);  //Ideally would like to have these 3, but can't distinguish between return type AddColumn and AlterColumn at compiletime
    m.Alter.Table("").AlterColumn("").AsInt16().SetIdentity(PostgresGenerationType.Always);
    m.Alter.Table("").AlterColumn("").AsInt16().DropIdentity(false);
    

    Fields

    Concurrently

    Declaration
    public const string Concurrently = "PostgresConcurrently"
    Field Value
    Type Description
    string

    IncludesList

    Declaration
    public const string IncludesList = "PostgresIncludes"
    Field Value
    Type Description
    string

    IndexAlgorithm

    Declaration
    public const string IndexAlgorithm = "PostgresIndexAlgorithm"
    Field Value
    Type Description
    string

    IndexAutosummarize

    Declaration
    public const string IndexAutosummarize = "PostgresBrinautosummarize"
    Field Value
    Type Description
    string

    IndexBuffering

    Declaration
    public const string IndexBuffering = "PostgresGiSTBuffering"
    Field Value
    Type Description
    string

    IndexColumnNullsDistinct

    Declaration
    public const string IndexColumnNullsDistinct = "PostgresIndexColumnNullsDistinct"
    Field Value
    Type Description
    string

    IndexFastUpdate

    Declaration
    public const string IndexFastUpdate = "PostgresGinFastUpdate"
    Field Value
    Type Description
    string

    IndexFillFactor

    Declaration
    public const string IndexFillFactor = "PostgresFillFactor"
    Field Value
    Type Description
    string

    IndexFilter

    Declaration
    public const string IndexFilter = "PostgresIndexFilter"
    Field Value
    Type Description
    string

    IndexGinPendingListLimit

    Declaration
    public const string IndexGinPendingListLimit = "PostgresGinPendingListLimit"
    Field Value
    Type Description
    string

    IndexPagesPerRange

    Declaration
    public const string IndexPagesPerRange = "PostgresBrinPagesPerRange"
    Field Value
    Type Description
    string

    IndexTablespace

    Declaration
    public const string IndexTablespace = "PostgresTablespace"
    Field Value
    Type Description
    string

    IndexVacuumCleanupIndexScaleFactor

    Declaration
    public const string IndexVacuumCleanupIndexScaleFactor = "PostgresBTreeVacuumCleanupIndexScaleFactor"
    Field Value
    Type Description
    string

    NullsSort

    Declaration
    public const string NullsSort = "PostgresNulls"
    Field Value
    Type Description
    string

    Only

    Declaration
    public const string Only = "PostgresOnly"
    Field Value
    Type Description
    string

    OverridingIdentityValues

    Declaration
    public const string OverridingIdentityValues = "PostgresOverridingIdentityValues"
    Field Value
    Type Description
    string

    Properties

    IdentityGeneration

    Column identity generation ability for PostgreSQL 10 and above

    Declaration
    public static string IdentityGeneration { get; }
    Property Value
    Type Description
    string

    IdentityModificationType

    Column identity modification type for PostgreSQL 10 and above

    Declaration
    public static string IdentityModificationType { get; }
    Property Value
    Type Description
    string

    Methods

    AddIdentity(IAlterColumnOptionSyntax, PostgresGenerationType)

    Adds a generated identity to the column

    Declaration
    public static IAlterColumnOptionSyntax AddIdentity(this IAlterColumnOptionSyntax expression, PostgresGenerationType generation)
    Parameters
    Type Name Description
    IAlterColumnOptionSyntax expression
    PostgresGenerationType generation
    Returns
    Type Description
    IAlterColumnOptionSyntax

    The next step

    Remarks

    This is an equivalent to Alter.Table.AlterColumn.Identity(PostgresGenerationType) Deliberate choice to extend IAlterColumnOptionSyntax rather than IColumnOptionSyntax<TNext, TNextFk> in order to prevent using these methods when adding a column to the table, since it makes no sense. It does mean the syntax migration.Alter.Table("tableName").AlterColumn("columnName") cannot be used since no distinction is made between the the return types of AddColumn or AlterColumn on the IAlterTableColumnAsTypeSyntax interface which is inconvenient but helps prevent misuse.

    AsConcurrently(ICreateIndexOptionsSyntax)

    When this option is used, PostgreSQL will build the index without taking any locks that prevent concurrent inserts, updates, or deletes on the table Whereas a standard index build locks out writes (but not reads) on the table until it's done. There are several caveats to be aware of when using this option

    Declaration
    public static ICreateIndexOptionsSyntax AsConcurrently(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    Remarks

    To use this feature is necessary mark the migration to not use transaction. sample: [Migration(1, TransactionBehavior.None)] public class SomeMigration : Migration

    AsConcurrently(ICreateIndexOptionsSyntax, bool)

    When this option is used, PostgreSQL will build the index without taking any locks that prevent concurrent inserts, updates, or deletes on the table Whereas a standard index build locks out writes (but not reads) on the table until it's done. There are several caveats to be aware of when using this option

    Declaration
    public static ICreateIndexOptionsSyntax AsConcurrently(this ICreateIndexOptionsSyntax expression, bool isConcurrently)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    bool isConcurrently

    if should or shouldn't be concurrently

    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    Remarks

    To use this feature is necessary mark the migration to not use transaction. sample: [Migration(1, TransactionBehavior.None)] public class SomeMigration : Migration

    AsOnly(ICreateIndexOptionsSyntax)

    Indicates not to recurse creating indexes on partitions, if the table is partitioned.

    Declaration
    public static ICreateIndexOptionsSyntax AsOnly(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    AsOnly(ICreateIndexOptionsSyntax, bool)

    Indicates not to recurse creating indexes on partitions, if the table is partitioned.

    Declaration
    public static ICreateIndexOptionsSyntax AsOnly(this ICreateIndexOptionsSyntax expression, bool isOnly)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    bool isOnly

    if should or shouldn't be only

    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    DropIdentity(IAlterColumnOptionSyntax, bool)

    Drops an existing identity on the column

    Declaration
    public static IAlterColumnOptionSyntax DropIdentity(this IAlterColumnOptionSyntax expression, bool ifExists)
    Parameters
    Type Name Description
    IAlterColumnOptionSyntax expression
    bool ifExists

    If true and the column is not an identity column, no error is thrown. In this case a notice is issued instead.

    Returns
    Type Description
    IAlterColumnOptionSyntax

    The next step

    Remarks

    Deliberate choice to extend IAlterColumnOptionSyntax rather than IColumnOptionSyntax<TNext, TNextFk> in order to prevent using these methods when adding a column to the table, since it makes no sense. It does mean the syntax migration.Alter.Table("tableName").AlterColumn("columnName") cannot be used since no distinction is made between the the return types of AddColumn or AlterColumn on the IAlterTableColumnAsTypeSyntax interface which is inconvenient but helps prevent misuse.

    Fillfactor(ICreateIndexOptionsSyntax, int)

    The fillfactor for an index is a percentage that determines how full the index method will try to pack index pages.

    Declaration
    public static ICreateBTreeIndexOptionsSyntax Fillfactor(this ICreateIndexOptionsSyntax expression, int fillfactor)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    int fillfactor

    The fillfactor value from 10 to 100 can be selected

    Returns
    Type Description
    ICreateBTreeIndexOptionsSyntax

    The next step

    Remarks

    For B-trees, leaf pages are filled to this percentage during initial index build, and also when extending the index at the right (adding new largest key values). If pages subsequently become completely full, they will be split, leading to gradual degradation in the index's efficiency. B-trees use a default fillfactor of 90, but any integer value from 10 to 100 can be selected. If the table is static then fillfactor 100 is best to minimize the index's physical size, but for heavily updated tables a smaller fillfactor is better to minimize the need for page splits. The other index methods use fillfactor in different but roughly analogous ways; the default fillfactor varies between methods.

    Filter(ICreateIndexOptionsSyntax, string)

    The constraint expression for a partial index. For more information about partial index see: https://www.postgresql.org/docs/current/indexes-partial.html

    Declaration
    public static ICreateIndexOptionsSyntax Filter(this ICreateIndexOptionsSyntax expression, string filter)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    string filter

    The constraint expression

    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    Identity<TNext, TNextFk>(IColumnOptionSyntax<TNext, TNextFk>, PostgresGenerationType)

    Sets the column's identity generation attribute. To change or remove an existing one, use Alter.Column instead of Alter.Table.AlterColumn

    Declaration
    public static TNext Identity<TNext, TNextFk>(this IColumnOptionSyntax<TNext, TNextFk> expression, PostgresGenerationType generation) where TNext : IFluentSyntax where TNextFk : IFluentSyntax
    Parameters
    Type Name Description
    IColumnOptionSyntax<TNext, TNextFk> expression
    PostgresGenerationType generation
    Returns
    Type Description
    TNext

    The next step

    Type Parameters
    Name Description
    TNext
    TNextFk

    Include(ICreateIndexOnColumnSyntax, string)

    Declaration
    public static ICreateIndexNonKeyColumnSyntax Include(this ICreateIndexOnColumnSyntax expression, string columnName)
    Parameters
    Type Name Description
    ICreateIndexOnColumnSyntax expression
    string columnName
    Returns
    Type Description
    ICreateIndexNonKeyColumnSyntax

    Include(ICreateIndexOptionsSyntax, string)

    Declaration
    public static ICreateIndexOptionsSyntax Include(this ICreateIndexOptionsSyntax expression, string columnName)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    string columnName
    Returns
    Type Description
    ICreateIndexOptionsSyntax

    Nulls(ICreateIndexMoreColumnOptionsSyntax, NullSort)

    Specifies that nulls sort before non-nulls.

    Declaration
    public static ICreateIndexMoreColumnOptionsSyntax Nulls(this ICreateIndexMoreColumnOptionsSyntax expression, NullSort sort)
    Parameters
    Type Name Description
    ICreateIndexMoreColumnOptionsSyntax expression

    The ICreateIndexMoreColumnOptionsSyntax

    NullSort sort

    The NullsSort.

    Returns
    Type Description
    ICreateIndexMoreColumnOptionsSyntax

    The ICreateIndexMoreColumnOptionsSyntax

    NullsDistinct(ICreateIndexColumnUniqueOptionsSyntax, bool)

    Column should have unique values. Only one row with null value should be accepted (default for most known database engines).

    Declaration
    public static ICreateIndexColumnUniqueOptionsSyntax NullsDistinct(this ICreateIndexColumnUniqueOptionsSyntax expression, bool nullsAreDistinct = true)
    Parameters
    Type Name Description
    ICreateIndexColumnUniqueOptionsSyntax expression

    The expression to set this option for

    bool nullsAreDistinct

    true when nulls should be distinct

    Returns
    Type Description
    ICreateIndexColumnUniqueOptionsSyntax

    The expression

    NullsDistinct(ICreateIndexMoreColumnOptionsSyntax, bool)

    Column should have unique values. Only one row with null value should be accepted (default for most known database engines).

    Declaration
    public static ICreateIndexOnColumnSyntax NullsDistinct(this ICreateIndexMoreColumnOptionsSyntax expression, bool nullsAreDistinct = true)
    Parameters
    Type Name Description
    ICreateIndexMoreColumnOptionsSyntax expression

    The expression to set this option for

    bool nullsAreDistinct

    true when nulls should be distinct

    Returns
    Type Description
    ICreateIndexOnColumnSyntax

    The expression

    NullsFirst(ICreateIndexMoreColumnOptionsSyntax)

    Specifies that nulls sort before non-nulls. This is the default when DESC is specified.

    Declaration
    public static ICreateIndexMoreColumnOptionsSyntax NullsFirst(this ICreateIndexMoreColumnOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexMoreColumnOptionsSyntax expression

    The ICreateIndexMoreColumnOptionsSyntax

    Returns
    Type Description
    ICreateIndexMoreColumnOptionsSyntax

    The ICreateIndexMoreColumnOptionsSyntax

    NullsLast(ICreateIndexMoreColumnOptionsSyntax)

    Specifies that nulls sort after non-nulls. This is the default when DESC is not specified.

    Declaration
    public static ICreateIndexMoreColumnOptionsSyntax NullsLast(this ICreateIndexMoreColumnOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexMoreColumnOptionsSyntax expression

    The ICreateIndexMoreColumnOptionsSyntax

    Returns
    Type Description
    ICreateIndexMoreColumnOptionsSyntax

    The ICreateIndexMoreColumnOptionsSyntax

    NullsNotDistinct(ICreateIndexColumnUniqueOptionsSyntax)

    Column should have unique values, but multiple rows with null values should be accepted.

    Declaration
    public static ICreateIndexColumnUniqueOptionsSyntax NullsNotDistinct(this ICreateIndexColumnUniqueOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexColumnUniqueOptionsSyntax expression

    The expression to set this option for

    Returns
    Type Description
    ICreateIndexColumnUniqueOptionsSyntax

    The expression

    NullsNotDistinct(ICreateIndexMoreColumnOptionsSyntax)

    Column should have unique values, but multiple rows with null values should be accepted.

    Declaration
    public static ICreateIndexOnColumnSyntax NullsNotDistinct(this ICreateIndexMoreColumnOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexMoreColumnOptionsSyntax expression

    The expression to set this option for

    Returns
    Type Description
    ICreateIndexOnColumnSyntax

    The expression

    SetIdentity(IAlterColumnOptionSyntax, PostgresGenerationType)

    Alters the strategy for an existing generated identity on the column

    Declaration
    public static IAlterColumnOptionSyntax SetIdentity(this IAlterColumnOptionSyntax expression, PostgresGenerationType generation)
    Parameters
    Type Name Description
    IAlterColumnOptionSyntax expression
    PostgresGenerationType generation
    Returns
    Type Description
    IAlterColumnOptionSyntax

    The next step

    Remarks

    Deliberate choice to extend IAlterColumnOptionSyntax rather than IColumnOptionSyntax<TNext, TNextFk> in order to prevent using these methods when adding a column to the table, since it makes no sense. It does mean the syntax migration.Alter.Table("tableName").AlterColumn("columnName") cannot be used since no distinction is made between the the return types of AddColumn or AlterColumn on the IAlterTableColumnAsTypeSyntax interface which is inconvenient but helps prevent misuse.

    Tablespace(ICreateIndexOptionsSyntax, string)

    The tablespace in which to create the index. If not specified, default_tablespace is consulted, or temp_tablespaces for indexes on temporary tables.

    Declaration
    public static ICreateIndexOptionsSyntax Tablespace(this ICreateIndexOptionsSyntax expression, string tablespace)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    string tablespace

    The tablespace

    Returns
    Type Description
    ICreateIndexOptionsSyntax

    The next step

    UniqueNullsDistinct(ICreateIndexOptionsSyntax, bool)

    Index should have unique values. Only one row with null value should be accepted (default for most known database engines).

    Declaration
    public static ICreateIndexOnColumnSyntax UniqueNullsDistinct(this ICreateIndexOptionsSyntax expression, bool nullsAreDistinct = true)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression

    The expression to set this option for

    bool nullsAreDistinct

    true when nulls should be distinct

    Returns
    Type Description
    ICreateIndexOnColumnSyntax

    The expression

    UniqueNullsNotDistinct(ICreateIndexOptionsSyntax)

    Index should have unique values, but multiple rows with null values should be accepted.

    Declaration
    public static ICreateIndexOnColumnSyntax UniqueNullsNotDistinct(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression

    The expression to set this option for

    Returns
    Type Description
    ICreateIndexOnColumnSyntax

    The expression

    Using(ICreateIndexOptionsSyntax, Algorithm)

    Declaration
    public static ICreateIndexMethodOptionsSyntax Using(this ICreateIndexOptionsSyntax expression, Algorithm algorithm)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Algorithm algorithm
    Returns
    Type Description
    ICreateIndexMethodOptionsSyntax

    Using(ISupportAdditionalFeatures, Algorithm)

    Declaration
    public static void Using(this ISupportAdditionalFeatures additionalFeatures, Algorithm algorithm)
    Parameters
    Type Name Description
    ISupportAdditionalFeatures additionalFeatures
    Algorithm algorithm

    UsingBTree(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateBTreeIndexOptionsSyntax UsingBTree(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateBTreeIndexOptionsSyntax

    UsingBrin(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateBrinIndexOptionsSyntax UsingBrin(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateBrinIndexOptionsSyntax

    UsingGin(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateGinIndexOptionsSyntax UsingGin(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateGinIndexOptionsSyntax

    UsingGist(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateGiSTIndexOptionsSyntax UsingGist(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateGiSTIndexOptionsSyntax

    UsingHash(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateHashIndexOptionSyntax UsingHash(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateHashIndexOptionSyntax

    UsingSpgist(ICreateIndexOptionsSyntax)

    Declaration
    public static ICreateSpgistIndexOptionsSyntax UsingSpgist(this ICreateIndexOptionsSyntax expression)
    Parameters
    Type Name Description
    ICreateIndexOptionsSyntax expression
    Returns
    Type Description
    ICreateSpgistIndexOptionsSyntax

    WithOverridingSystemValue(IInsertDataSyntax)

    Adds an OVERRIDING SYSTEM VALUE clause in the current IInsertDataSyntax expression. This enables the system-generated values to be overriden with the user-specified explicit values (other than DEFAULT) for identity columns defined as GENERATED ALWAYS

    Declaration
    public static IInsertDataSyntax WithOverridingSystemValue(this IInsertDataSyntax expression)
    Parameters
    Type Name Description
    IInsertDataSyntax expression

    The current IInsertDataSyntax expression

    Returns
    Type Description
    IInsertDataSyntax

    The current IInsertDataSyntax expression

    WithOverridingUserValue(IInsertDataSyntax)

    Adds an OVERRIDING USER VALUE clause in the current IInsertDataSyntax expression. Any user-specified values will be ignored and the system-generated values will be applied for identity columns defined as GENERATED BY DEFAULT

    Declaration
    public static IInsertDataSyntax WithOverridingUserValue(this IInsertDataSyntax expression)
    Parameters
    Type Name Description
    IInsertDataSyntax expression

    The current IInsertDataSyntax expression

    Returns
    Type Description
    IInsertDataSyntax

    The current IInsertDataSyntax expression

    In this article
    Back to top
    Copyright © 2018 Fluent Migrator Project
    Generated by DocFX
    Creative Commons License
    FluentMigrator Documentation by FluentMigrator Project is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.