When building a module you should always utilise the installation and upgrade scripts so that any database additions or changes are automatically modified on module installation. There are a number of built in functions to these modules allowing you to add attributes, create new tables etc.

It’s common to want to add another column onto an already created table, you could just run the raw SQL code in the installer script to make these changes. Magento has a built in function called addColumn which can do the heavy lifting for you.

Heres an example of adding column_name to the table defined as module/entity. You can call this function in either the installation of upgrade scripts.

Dave Macaulay
Dave Macaulay
I'm an enthusiastic, slightly eccentric Magento developer who bores with the idea of another basic brief.
  • Yehuda Schwartz

    I need this column to only have unique values (it is not the tables primary key), also is there a way to only allow lowercase and no special characters (only a-z) thanks for the help!