title: Adding new columns to table dynamically for custom fields
body: <p>I am building a custom field feature for my application. This allows the administrator to add custom profile fields for users to fill in depending on the site's needs.</p>
  
  <p>The schema is simple</p>
  
  <pre><code>field_meta (store some metadata about the field)
  ================================================
  id
  type //type of field
  field_name //name of the field in the fields table
  render_data //Some data to use when rendering the form field
  
  field
  ===================
  id
  name //Default field that can't be deleted
  address //Default field that can't be deleted
  customfield_1
  customfield_2
  </code></pre>
  
  <p>The <code>field_meta</code> table is used to store some meta data for the field, so that we can render the form fields.</p>
  
  <p>Each field is then stored in a new column in the <code>field</code> table.</p>
  
  <p>Problem:
  For usability and to not have to deal with users choosing reserved words or using non-english words for the column name, I will not be asking users to choose a name for the column name.</p>
  
  <p>I am currently considering calling the column name by field type (there are quite a few types in the application (email, website, text, paragraphtext, etc), just to name a few) and adding a number. Some examples:</p>
  
  <ul>
  <li>Email_1</li>
  <li>Text_1</li>
  <li>Text_2</li>
  <li>Text_3</li>
  <li>Email_2</li>
  <li>etc</li>
  </ul>
  
  <p>However, the problem with this approach is that it takes a fair bit of work to come up with the column name. I need to get all the columns, pick out the ones with the same column type as I am creating, parse for the largest number, and then create the column.</p>
  
  <p>Is there a better strategy to do this? Or perhaps a totally different way to name the columns that eliminates these problems?</p>