go-gorm / go-gorm/postgres

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

Open
#180 0 comments 0 reactions 1 assignee Claimed by @jinzhu View on GitHub
Dominant language
Go
Stars
297
Forks
155
Avg merge
27m
Merged PRs (30d)
2

Description

## GORM Playground Link

https://github.com/go-gorm/playground/pull/595

## Description

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

```bash
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`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.