title: Adding columns in mySQL Workbench Model using Shell Script
body: <p>I need to add the following 2 columns to all the tables in my model (mwb file)</p>
  
  <ul>
  <li><code>created</code></li>
  <li><code>updated</code></li>
  </ul>
  
  <p>Because there are many tables to be modified, instead of doing it manually I found the <a href="http://mysqlworkbench.org/2012/06/mysql-workbench-script-for-adding-columns-to-all-tables-in-a-model/" rel="nofollow noreferrer">following script</a></p>
  
  <pre><code># get a reference to the schema in the model. This will get the 1st schema in it.
  schema = grt.root.wb.doc.physicalModels[0].catalog.schemata[0]
  # iterate through all tables
  for table in schema.tables:
      # create a new column object and set its name
      column = grt.classes.db_mysql_Column()
      column.name = "created"
      # add it to the table
      table.addColumn(column)
      # set the datatype of the column
      column.setParseType("TIMESTAMP", None)
      column.defaultValue = "CURRENT_TIMESTAMP"
  
      # same thing for the update_time column
      column = grt.classes.db_mysql_Column()
      column.name = "updated"
      table.addColumn(column)
      column.setParseType("TIMESTAMP", None)
  </code></pre>
  
  <p>The script is working fine (I added the columns to all my table) but those columns are added at the end of each table.</p>
  
  <p>I want to add them in 2nd and 3rd position, right after the primary key in 1st position. </p>
  
  <p>I looked at the <a href="http://wb.fabforce.eu/doc/globals/classdb__mysql___column-members.html" rel="nofollow noreferrer">db_mysql_Column</a> definition, but I cannot see any data relevant to the position.</p>
  
  <p>Also, the <a href="http://wb.fabforce.eu/doc/globals/classdb___table.html#a6c3e505e9f8396529b62bc59b06639a9" rel="nofollow noreferrer">addColumn</a> method does not allows an overload with some sort of position</p>
  
  <p>Is there a way to do it?     </p>