Posted by Simon on 06/09/05 19:11
Hi,
We have a small utility that uses a database.
We are happy with the structure of the database but we cannot predict any
updates.
What we are particularly concerned about are updates vs. new installs.
We have an install that does something like...
.....
CREATE DATABASE "my_db" DEFAULT CHARACTER SET latin1 COLLATE
latin1_swedish_ci;
USE my_db;
CREATE TABLE IF NOT EXISTS "my_table" (
"id" int(11) NOT NULL default '0'
)
....
if we create a new field we would update our install script
....
CREATE TABLE IF NOT EXISTS "my_table" (
"id" int(11) NOT NULL default '0',
"anotherid" int(11) NOT NULL default '0'
)
....
But what about users that already have the table? how can I check if the
field needs to be added?
ALTER TABLE "my_table" ADD "anotherid" INT( 11 ) NOT NULL default '0'
Ideally the script would be self sufficient so we don't have versions to
compare. I would check if the field exists, and if it doesn't alter the
table.
Many thanks in advance.
Simon
[Back to original message]
|