To make it a bit easier to write the sql scripts for creating and dropping tables, I wrote a simple bake task. There isn’t much to say about it, so I show you just an example.

The following call:

php bake2.php sqlscripts users profiles profiles_users

creates app/config/sql/create.sql:

CREATE TABLE users (
  id INT(11) NOT NULL AUTO_INCREMENT,
  created DATETIME,
  modified DATETIME,
  PRIMARY KEY (id)
); 

CREATE TABLE profiles (
  id INT(11) NOT NULL AUTO_INCREMENT,
  created DATETIME,
  modified DATETIME,
  PRIMARY KEY (id)
); 

CREATE TABLE profiles_users (
  profile_id INT(11) NOT NULL,
  user_id INT(11) NOT NULL,
  PRIMARY KEY (profile_id, user_id)
);

and app/config/sql/drop.sql:

DROP TABLE IF EXISTS users;

DROP TABLE IF EXISTS profiles;

DROP TABLE IF EXISTS profiles_users;

That’s it. You can find the code in the download section. Happy baking :)