Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing postgres type aliases #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lasse-it
Copy link

@lasse-it lasse-it commented Apr 4, 2024

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

A bunch of Postgres-type aliases are missing in the migrator. AutoMigrate performs an ALTER COLUMN even though the column already has the specified data type.

This PR adds the missing aliases, ensuring that the migrator doesn't execute the ALTER COLUMN statement, when the given column is already migrated.

The complete list of aliases is in Table 8.1 in the Postgres documentation here.

User Case Description

Adding these aliases ensures that ALTER COLUMN isn't performed when invoking AutoMigrate on a table, where the columns used one of the following types:

  • integer
  • smallserial
  • serial
  • bigserial
  • bit varying
  • character
  • character varying
  • real
  • double precision
  • time with time zone

Copy link
Member

@a631807682 a631807682 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, can you add some tests in https://github.com/go-gorm/gorm ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants