-
Notifications
You must be signed in to change notification settings - Fork 674
Developer Guide: How to Change the Database Structure
If you need to alter the structure of the ThinkUp database, here’s how.
In the sql/mysql_migrations/
folder, create a new .sql
file. The name should include the date, issue number, and a short description of what you’re doing.
For example, if I’m altering the database for my work on issue #200 on May 3, 2010 and I want to add a field called my_field
to the posts table, I’d create a file called: 2010-05-03_add-myfield-to-posts_issue200.sql
.
In that file, add the SQL alter statements. For example, ALTER TABLE tu_posts ADD myfield VARCHAR( 255 ) NOT NULL;
.
Once you have confirmed that your migration script works, regenerate the sql/build-db_mysql.sql
file using the automated migratedb
shell script. Never edit the build-db_mysql.sql
file by hand.
To do so, run the extras/scripts/migratedb
script at the command line. First you’ll need to create and edit your configuration file. Check out the README for instructions on how to do that.
Run ThinkUp’s tests to make sure the database creation script works. When you commit your work, make sure you add both the new migration file, and the auto-generated build-db_mysql.sql
file.
There is no step 3.