ActiveRecord::Schema.define do
create_table :arts do |t|
t.string :name, :null => false, :limit => 45
end
end
This file is saved into test/db/schema.rb, and test/config/database.yml
is correctly configured with "test_development" database created in a
MySQL server.
Could you help me to install the content of schema.rb file in MySQL and
in my Rails 2 application?
ActiveRecord::Schema.define do
create_table :arts do |t|
t.string :name, :null => false, :limit => 45
end
end
This file is saved into test/db/schema.rb, and test/config/database.yml
is correctly configured with "test_development" database created in a
MySQL server.
Well, this is a rather awkward way of doing things. Effectively,
db/schema.rb is a composite migration file. To load it one would
typically move it to something called similar to
db/migrate/001_initial_db_load.rb and run rake db:migrate. When one
runs the rake task, depending upon the settings in
config/environment.rb, then db/schema.rb gets overwritten with the
results of the applied migrations, making direct editing of this file
rather pointless.
It would be far better for you to read up on migrations and to use
individual migrations contained in db/migrate instead.
Well, this is a rather awkward way of doing things. Effectively,
db/schema.rb is a composite migration file. To load it one would
typically move it to something called similar to
db/migrate/001_initial_db_load.rb and run rake db:migrate.
To load schema.rb. you do not need to move or rename anything,
just use rake db:schema:load
Well, this is a rather awkward way of doing things. Effectively,
db/schema.rb is a composite migration file. To load it one would
typically move it to something called similar to
db/migrate/001_initial_db_load.rb and run rake db:migrate.
To load schema.rb. you do not need to move or rename anything,
just use rake db:schema:load
By the way, I just have a last question: is there a command to
automaticly create all the model for any tables of my database? I ask
this because my database have 16 tables and I don't think using
"script/generate model <a table>" 16 times is a good idea.
That should work well as long as you don't have a singular/plural pair
that doesn't use "+s" for the plural (e.g., pony, ponies). You could
probably route your command through pluralize, but in that case, it
would be easier just to type in the 16 commands.