The 'modify' keyword is not supported in postgres
hyzx86 opened this issue · 12 comments
I don't understand what this code does. Why compare lengths?
yessql/src/YesSql.Provider.PostgreSql/PostgreSqlCommandInterpreter.cs
Lines 18 to 22 in c0771eb
SchemaBuilder.AlterIndexTable<AuditTrailEventIndex>(table => table
.AlterColumn(nameof(AuditTrailEventIndex.CorrelationId),
column => column.WithType(typeof(string), 255)),
collection: AuditTrailEvent.Collection
);
Error while running migration version 0 for 'EasyOC.AuditTrail'. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Npgsql.PostgresException (0x80004005): 42601: syntax error at or near "modify"
POSITION: 42
at Npgsql.Internal.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|221_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) in /_/Dapper/SqlMapper.cs:line 2848
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in /_/Dapper/SqlMapper.cs:line 581
at YesSql.Sql.SchemaBuilder.Execute(IEnumerable`1 statements)
at YesSql.Sql.SchemaBuilder.AlterTable(String name, Action`1 table)
at YesSql.Sql.SchemaBuilder.AlterIndexTable(Type indexType, Action`1 table, String collection)
at EasyOC.AuditTrail.Migrations.UpdateAuditTrailMigrations.Create() in D:\SourceCodes\JZSoft\EasyOC.OrchardCore\EasyOC\src\Modules\EasyOC.AuditTrail\Migrations\UpdateAuditTrailMigrations.cs:line 30
Exception data:
Severity: ERROR
SqlState: 42601
MessageText: syntax error at or near "modify"
Position: 42
File: scan.l
Line: 1133
Routine: scanner_yyerror
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at OrchardCore.Data.Migration.DataMigrationManager.UpdateAsync(String featureId) at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at OrchardCore.Data.Migration.DataMigrationManager.UpdateAsync(String featureId)
Use Alter Column
instead
Use
Alter Column
instead
Yes, This is the code I'm using now
This kind of problem seems very difficult to cover completely, can pass
Could you consider using other components to implement table structure migration?
For example:
https://github.com/fluentmigrator/fluentmigrator
@hishamco
So you think modify
should be changed to alter
but why are there two cases , alter
and modify
?
@sebastienros Can you help me look at this problem? thanks!
Could you point to the two cases? Also, modify your PR according to Seb comment
Could you point to the two cases? Also, modify your PR according to Seb comment
Ok, but I've been very busy lately. Lots of concurrent projects ~ My work is already scheduled after May 10th ~
This unit test shouldn't be difficult, it'll just take a little bit of time
If you don't have a time I can create a PR instead
Please leave it open until I create my PR or complete yours :)
Please leave it open until I create my PR or complete yours :)
it doesn't matter I only changed one word