Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Migration Builder filter ERROR for PostgreSQL #9565


User avatar
0
SASIMEXICO created

Zero 9.1.0 Angular ABP 5.8

        migrationBuilder.CreateIndex(
            name: "IX_AbpDynamicEntityProperties_EntityFullName_DynamicPropertyId_TenantId",
            table: "AbpDynamicEntityProperties",
            columns: new[] { "EntityFullName", "DynamicPropertyId", "TenantId" },
            unique: true,
            filter: "[EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL");

Working with PostgreSQL the migration cause this ERROR:

Applying migration '20200805083139_Upgraded_To_Abp_5_11'. Failed executing DbCommand (82ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE UNIQUE INDEX "IX_AbpDynamicEntityProperties_EntityFullName_DynamicPropertyId_TenantId" ON "AbpDynamicEntityProperties" ("EntityFullName", "DynamicPropertyId", "TenantId") WHERE [EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL; Npgsql.PostgresException (0x80004005): 42601: error de sintaxis en o cerca de «[» at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming) at Npgsql.NpgsqlDataReader.NextResult() at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteNonQuery() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable1 migrationCommands, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Exception data: Severity: ERROR SqlState: 42601 MessageText: error de sintaxis en o cerca de «[» Position: 185 File: scan.l Line: 1150 Routine: scanner_yyerror 42601: error de sintaxis en o cerca de «[»

The problem is with "filter" param in migrationBuilder.CreateIndex function. When I deleted this line filter: "[EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL" then the migration run perfect, but without those params.

How can I add filter param in migrationBuilder.CreateIndex function?

Thanks!


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi SASIMEXICO

    Have you remove the exist migration files and recreate new?

    https://aspnetboilerplate.com/Pages/Documents/EF-Core-PostgreSql-Integration