Prev | Current Page 119 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Migrations are
designed to be cross-platform, so you can usually run the same migration across multiple
databases. (Of course, if you use any database-specific features, the migration won??™t be
cross-platform.) Migrations are versioned, so you can upgrade and downgrade them as
you see fit. Rails also keeps track of the current version of your database, so if you have a
number of migrations, Rails will run only the new migrations.
Create a new migration by using the following command:
ruby script/generate migration initial_schema
CHAPTER 5 n CONNECTING YOUR REPORTS TO THE WORLD 78
create db/migrate
create db/migrate/001_initial_schema.rb
This creates a skeleton migration. The initial db/migrate/001_initial_schema.rb file
looks like this:
class InitialSchema < ActiveRecord::Migration
def self.up
end
def self.down
end
end
As you can see, it??™s a single class that inherits from ActiveRecord::Migration, and it
has two class methods: up and down, which upgrade and downgrade the version of the
database structure, respectively, when the migration is run.


Pages:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
architekt wnętrz Warszawa płyty meblowe zdrowy sen Bielizna erotyczna torebki