If you waited to create the tables, you can use the migrations to do it. Look under the
/application_root/db/migrate folder. Create a file called CreatePost.cfc. In it, we just
want to define some fields for our blog post. You can use this code:
<cfcomponent extends="cfrails.Migration">
<cffunction name="up" access="public">
<cfscript>
tableName = "post";
columns = structNew();
columns.user_id = "integer";
columns.title = "nvarchar(100) not null";
columns.meat = "ntext";
columns.date_created = "datetime";
columns.date_last_modified = "datetime";
columns.show_this_post = "bit";
create_table(tableName, columns, "user_id,title,meat,date_created,date_last_modified,show_this_post");
</cfscript>
</cffunction>
<cffunction name="down" access="public">
<cfset drop_table("post")>
</cffunction>
</cfcomponent>
Now, simply navigate your browser to the application_root/db/migrate/_run_migrations.cfm
and the all of the up() functions in the cfc's you have will be run. Out of the package,
it will only run the up() function if the table does not exist. To change this
behavior to automatically drop the table and add again, in the catch block in that file you
could do something like:
<cfset theObj.down()>
<cfset theObj.up()>