On Thu, Dec 22, 2005 at 10:38:13PM -0700, Carl Youngblood
wrote:> On a rails app that I''m developing I converted a regular old .sql
file
> into a rails migration. Since I generated the migration in my
> development environment, it created the schema_info table for me.
> However, when I updated my production environment and tried running
> rake migrate it complained that schema_info doesn''t exist. Is
there a
> rake task for getting around this yet, or some other elegant solution?
> So far it seems I have to manually create the schema_info table in
> each database that I want to use migrations on. Is this right?
I''m under the impression that migrations will automatically take care
of
creating the schema_info table for you if it is not there regardless of your
environment. Base.connection.initialize_schema_information is the first thing
called when you run a migration, which creates the table, or silently moves
along if the table is already there. What you''ve experienced sounds
anomalous. If you can recreate it please post a ticket.
On a side note, rather than create an initial migration, you could define
your schema in db/schema.rb file. Then you can run ''rake
db_schema_import''.
The schema.rb file will subsequently be generated automatically for you (if
config.active_record.schema_format is set to :ruby in your
config/environment.rb), so hence forth you won''t want to manually edit
it.
The format of the file is pretty similar to migrations:
ActiveRecord::Schema.define do
create_table :foos do |t|
t.column :bar, :string
t.column :baz, :string
t.column :quux, :integer
end
end
Another approach when just starting out is to use some db administration tool
to build up an initial schema. Then you can run ''rake
db_schema_dump'' and
you''ll have your first schema file ready to be imported into, e.g.,
your
production database.
>From then on out you''ll want to go with migrations and running them
will take
care of automatically dumping the schema for you which you can import at any
time.
marcel
--
Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org>