title: Postgresql: auto lowercase text while (or before) inserting to a column
body: <p>I want to achieve case insensitive uniqueness in a varchar column. But, there is no case insensitive text data type in Postgres. Since original case of text is not important, it will be a good idea to convert all to lowercase/uppercase before inserting in a column with UNIQUE constraint. Also, it will require one INDEX for quick search.</p>
  
  <p>Is there any way in Postgres to manipulate data before insertion?</p>
  
  <p>I looked at this other question: <a href="https://stackoverflow.com/questions/5518673/mysql-column-auto-convert-value-to-lowercase-how-to">How to automatically convert a MySQL column to lowercase</a>.
  It suggests using triggers on insert/update to lowercase text or to use views with lowercased text. But, none of the suggested methods ensure uniqueness.</p>
  
  <p>Also, since this data will be read/written by various applications, lowercasing data in every individual application is not a good idea.</p>