question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enum in migration not working (Postgres)

See original GitHub issue

Describe the bug A migration using enum type in postgres database isn’t working.

To Reproduce

  1. Create a migration with table.enum('gender', ['male', 'female'])
  2. Run migration

Expected behavior Constraint check is have to create normally.

Screenshots image

What database are you using? Postgres

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
josephmancusocommented, Feb 2, 2021

Lastly we can also do this. This requires to smallest change:

create table users12(
    genders VARCHAR(255) CHECK (genders IN ('male', 'female'))
);

This just requires adding {column} IN to the query

0reactions
josephmancusocommented, Feb 3, 2021

Fixed in #363

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration doesn't work when adding new value to enum and ...
Migration doesn't work when adding new value to enum and using new value as default, New enum values must be committed before they...
Read more >
sqlalchemy postgresql enum does not create type on db migrate
I have a problem with postgresql enum type on db migrate/upgrade. I added a column "status" to model: class Banner(db.
Read more >
Upgrading PostgreSQL's Enum type with SQLAlchemy using ...
In this tutorial we've successfully generated the migration file which can automatically upgrade enum types on PostgreSQL server. If you want to read...
Read more >
Documentation: 15: 8.7. Enumerated Types - PostgreSQL
Enumerated (enum) types are data types that comprise a static, ordered set of values. They are equivalent to the enum types supported in...
Read more >
Updating a Postgres Enum Column with a Laravel Migration
The enumerated data type (enum) provides a convenient way to constraint a column to a set of values. However, the implementation of enum...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found