I'm currently working on a system that is using two different databases. One of them is new and that's where most things happen, but I'm using an old database from another rails app somewhere else. Therefore I don't have the migrations for the database in my project. However I would like to be able to set up a script on Jenkins which will allow me to set that up so I can do CI. My database.yml file basically looks like this:
default: &default
adapter: postgresql
encoding: unicode
development:
<<: *default
database: proj_development
test:
<<: *default
database: proj_test
legacy_development:
<<: *default
database: legacy_development
legacy_test:
<<: *default
database: legacy_test
And I have a schema.rb from the old rails app that looks like this:
ActiveRecord::Schema.define(:version => 20140721152610) do
create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "password", :limit => 60
t.string "security_token", :limit => 32
t.text "additional_information"
end
create_table "email_addresses", :force => true do |t|
t.string "email"
t.datetime "verified_at"
t.string "status"
end
end
Is there a way that I can run a command to load that schema and set it so that legacy_test gets built with that schema? Some sort of rake db:schema:load --file=legacy_schema.rb --database=legacy_test
You can specify a custom schema file to load using SCHEMA
. So, to create the database defined in the legacy_development
environment and load the custom schema use:
rake db:create RAILS_ENV=legacy_development
rake db:schema:load RAILS_ENV=legacy_development SCHEMA=db/legacy_schema.rb
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.