Skip to content

Commit

Permalink
Prevent primary key update on migration (#26192)
Browse files Browse the repository at this point in the history
Fixes #25918

The migration fails on MSSQL because xorm tries to update the primary
key column. xorm prevents this if the column is marked as auto
increment:

https://gitea.com/xorm/xorm/src/commit/c622cdaf893fbfe3f40a6b79f6bc17ee10f53865/internal/statements/update.go#L38-L40

I think it would be better if xorm would check for primary key columns
here because updating such columns is bad practice. It looks like if
that auto increment check should do the same.

fyi @lunny
  • Loading branch information
KN4CK3R authored Jul 28, 2023
1 parent 494ee56 commit 7866a6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/migrations/v1_20/v250.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func ChangeContainerMetadataMultiArch(x *xorm.Engine) error {
}

type PackageVersion struct {
ID int64 `xorm:"pk"`
ID int64 `xorm:"pk autoincr"`
MetadataJSON string `xorm:"metadata_json"`
}

Expand Down

0 comments on commit 7866a6e

Please sign in to comment.