Skip to content

fail to alter existing boolean column from smallint with default value to boolean in postgres #180

Open
@jeffry-luqman

Description

@jeffry-luqman

GORM Playground Link

go-gorm/playground#595

Description

If we want to change boolean column from smallint with default value to boolean, it will report error like below:

2023/05/09 15:56:04 /home/ubuntu/temp/gorm-playground/main_test.go:41 ERROR: default for column "boolean_column" cannot be cast automatically to type boolean (SQLSTATE 42804)
[0.654ms] [rows:0] ALTER TABLE "column_structs" ALTER COLUMN "boolean_column" TYPE boolean USING "boolean_column"::INT::boolean

We only need to drop existing default value in func AlterColumn in postgres@v1.5.0/migrator.go

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions