tasks/database.rake in rubyrep-1.0.1 vs tasks/database.rake in rubyrep-1.0.2
- old
+ new
@@ -100,15 +100,17 @@
execute "drop schema rr cascade"
end
end
# Creates the sample schema in the database specified by the given
-# configuration hash.
-def create_sample_schema(config)
- create_postgres_schema config
+# configuration.
+# * :+database+: either :+left+ or +:right+
+# * :+config+: the Configuration object
+def create_sample_schema(database, config)
+ create_postgres_schema config.send(database)
- ActiveRecord::Base.establish_connection config
+ ActiveRecord::Base.establish_connection config.send(database)
ActiveRecord::Schema.define do
create_table :scanner_text_key, :id => false do |t|
t.column :text_id, :string
t.column :name, :string
@@ -250,15 +252,15 @@
t.column :name, :string
end
create_table :left_table do |t|
t.column :name, :string
- end
+ end if database == :left
create_table :right_table do |t|
t.column :name, :string
- end
+ end if database == :right
end
end
# Removes all tables from the sample scheme
# config: Hash of configuration values for the desired database connection
@@ -408,11 +410,11 @@
desc "Rebuilds the test databases & schemas"
task :rebuild => [:drop_schema, :drop, :create, :create_schema, :populate]
desc "Create the sample schemas"
task :create_schema do
- create_sample_schema RR::Initializer.configuration.left rescue nil
- create_sample_schema RR::Initializer.configuration.right rescue nil
+ create_sample_schema :left, RR::Initializer.configuration rescue nil
+ create_sample_schema :right, RR::Initializer.configuration rescue nil
end
desc "Writes the sample data"
task :populate do
create_sample_data
\ No newline at end of file