Rails creating a table without migration Rails creating a table without migration heroku heroku

Rails creating a table without migration


I think the simple answer is "don't use migrations" -- they are designed to help you relatively gracefully extend an otherwise static database schema. A migration does many things beyond generating/executing the data definition language (DDL) of your database -- it knows how to go forward and backward, knows by a linkage between source code (schema.rb) and data (in the schema_migrations table) how to determine which migrations need to be run, and so on. All you need is the part that executes the DDL (which is, after all, just a kind of SQL).

And at least some of that part is here in the TableDefinition API. All of the infrastructure you might need seems to be present.


You can set this up as a rake task (it sounds like what you are using it as) that contains the SQL/rails commands used to construct the table, similar to what is done with rake db:seed