Tips and Tricks -- Modifying Columns (was Re: [ic] TIPS: Adding a new mysql table to IC)

Corey Gilmore interchange-users@interchange.redhat.com
Thu Sep 27 10:22:00 2001


On Thu, 27 Sep 2001, Zack Johnson wrote:

> > I know I've fought this before.  Like if you add a column in mysql and
>
> Not to be a bugbear, but this is beyond the scope of my little micro-HOWTO
> on adding new tables.  You are talking about modifying existing tables.
> Perhaps you could write-up a micro-HOWTO on modifying mysql tables?

Using IC 4.6.5, when I want to add a new column to the products database,
I do this:

Load mysql, add a new column.

ALTER TABLE products ADD COLUMN prod_summary varchar(255);

The column is now in the database.

Edit catalogdir/catalog/dbconf/mysql/products.mysql

It should look something like
# MiniVend database definition
Database  products  products.txt __SQLDSN__
#ifdef SQLUSER
Database  products  USER         __SQLUSER__
#endif
#ifdef SQLPASS
Database  products  PASS         __SQLPASS__
#endif
Database  products  KEY          sku
...

We need to add our new column to this list
Add
Database  products  COLUMN_DEF   "prod_summary=(VARCHAR255)"
to the end of the file, save changes and close.

Here, I Apply Changes within the Admin UI.  This may not be necessary, but
doesn't seem to hurt.

I jump over to the Admin UI, and goto the Administration section.
Choose Knar and edit the variable table (default).

Search for the UI_ITEM_FIELDS variable.

It will resemble
sku description comment category type image display price nontaxable related featured required inactive weight shipping

These fields are the ones that are shown when you edit/create a product.
If you only wanted to view/edit the sku, description, comment and category
you would just add those fields.

The order the column names appear in the UI_ITEM_FIELDS variable
determines the order they will appear in when an Item is edited.

Add prod_summary (our new column name) where ever you want it to show.
Lets put it after comment.

sku description comment prod_summary category type image display price nontaxable related  featured required inactive weight shipping

Click OK.  Now to synchronize the products.txt with the database, you need
to export.


Goto Tables in the Admin UI, and export the products table using the
default settings.  I Apply Changes once more here.

Now go and edit an item.  The new field prod_summary will appear.  Click
'meta' and you can edit your display settings.

I've found (with 4.6.5) that after I edit the meta for the field, it
returns me to the previous page - without any other fields.  I click OK
until I return to the main Items page, and THEN the meta information is
saved.

This is a little rough, and some of the information may be extraneous,
but I have finance homework due in 30 minutes ;)

.cfg