Change the database column type to VARCHAR(30). CHAR(30) enforces a length of 30 which is why you have the trailing spaces. I think this is the preferred model
Use String.trim_trailing(column, " ") after you do any database operations.
Implement a customer Ecto type that does the trimming for you (but not really the best use of a customer type)