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

Use native enums if the database supports them #18

Open
thedrow opened this issue Jan 5, 2015 · 8 comments
Open

Use native enums if the database supports them #18

thedrow opened this issue Jan 5, 2015 · 8 comments

Comments

@thedrow
Copy link
Contributor

thedrow commented Jan 5, 2015

All major databases that Django support already supports enums at the database level.

You can also implement enums in SQLite using CHECK.

Is there a good way to hook into south and django migrations framework in order to make this field use their native database type?

@hannseman
Copy link
Contributor

Good idea, it would be interesting to try it out. It could be as simple as overriding db_type on the EnumField-class.

https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#custom-database-types

@thedrow
Copy link
Contributor Author

thedrow commented Jan 8, 2015

In postgres you have to run CREATE TYPE first so a migration is required.
On the other databases it should be a matter of overrriding db_type.

@AncientSwordRage
Copy link

Any progress on this?

@thedrow
Copy link
Contributor Author

thedrow commented Feb 9, 2015

I'm gonna try to implement it when I'm in London.
The next Django sprint will take place there.

@kjagiello
Copy link
Contributor

"2. Changing the member list of ENUM columns is very expensive."
http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

@kaidokert
Copy link

I'm looking at a different path, which would have enum values in a classic lookup table with foreign key instead. The table has auto_id, enum_value, enum_label , and i'm trying to come up with a reasonably safe sync method that updates existing databases with new model code from the enum classes as needed.

django-enumfield is cool as its implemented, but i really want to enforce referential integrity at the db level, and also have my database make sense to someone who has never looked at django/python at all.

If someone has done this already, i'd appreciate a pointer.

@PiDelport
Copy link

@HaddadJoe
Copy link

is this a stale issue? looks like the issue is dormant on the upstream django tickets board. it would be nice if this library can support it.

Happy to open a PR if it would be considered

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

No branches or pull requests

7 participants