# Ecto Schema: Enum Data Type?

**URL:** <https://forum.elixirforum.com/t/ecto-schema-enum-data-type/14726>\
**Category:** Questions\
**Tags:** ecto, schema\
**Created:** [June 18, 2018, 3:42am UTC](https://forum.elixirforum.com/t/ecto-schema-enum-data-type/14726 "2018-06-18T03:42:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [June 18, 2018, 3:37pm UTC](https://forum.elixirforum.com/t/ecto-schema-enum-data-type/14726/5 "2018-06-18T15:37:03Z")

</div>

Were you using postgres?

```sql
idiot@/tmp:enum_test> create type hello_type as enum ('a', 'b', 'c');
CREATE TYPE
Time: 0.021s
idiot@/tmp:enum_test> create table test (name varchar, type hello_type);
CREATE TABLE
Time: 0.018s
idiot@/tmp:enum_test> insert into test values ('hello', 'a');
INSERT 0 1
Time: 0.007s
idiot@/tmp:enum_test> insert into test values ('hello', 'b');
INSERT 0 1
Time: 0.001s
idiot@/tmp:enum_test> insert into test values ('hello', 'c');
INSERT 0 1
Time: 0.001s
idiot@/tmp:enum_test> select * from test;
+--------+--------+
| name | type |
|--------+--------|
| hello | a |
| hello | b |
| hello | c |
+--------+--------+
SELECT 3
Time: 0.008s
idiot@/tmp:enum_test> alter type hello_type add value 'd' after 'a';
ALTER TYPE
Time: 0.004s
idiot@/tmp:enum_test> insert into test values ('hello', 'd');
INSERT 0 1
Time: 0.001s
idiot@/tmp:enum_test> select * from test;
+--------+--------+
| name | type |
|--------+--------|
| hello | a |
| hello | b |
| hello | c |
| hello | d |
+--------+--------+
SELECT 4
Time: 0.008s

```

Inserting new enum values works fine there. Deleting them is a bit more involved, but not by much, and it definitely wouldn’t destroy your data if done properly. Instead, using enum types would help keeping it consistent.

---

_[View the full topic](https://forum.elixirforum.com/t/ecto-schema-enum-data-type/14726)._
