Skip to content

Commit

Permalink
restore test/dummy migration for mock SFX db
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Mar 17, 2015
1 parent c07b2ec commit b584fb7
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
54 changes: 54 additions & 0 deletions test/dummy/db/migrate/20120927164040_sfx4_local.rb
@@ -0,0 +1,54 @@
# This is used for SFX search testing.
# DO NOT USE THIS FOR ANYTHING LIKE A REAL SFX DATABASE.
class Sfx4Local < ActiveRecord::Migration
def connection
if sfx4_mock_instance?
Sfx4::Local::Base.connection.initialize_schema_migrations_table
return Sfx4::Local::Base.connection
end
end

def change
if sfx4_mock_instance?
create_table "AZ_TITLE", {:id => false} do |t|
t.integer "AZ_TITLE_ID", :default => 0, :null => false
t.string "AZ_PROFILE", :limit => 100, :null => false
t.integer "OBJECT_ID", :default => 0, :null => false, :limit => 8
t.string "TITLE_DISPLAY", :limit => 255, :null => false
t.string "TITLE_SORT", :limit => 200, :null => false
t.string "SCRIPT", :limit => 20, :null => false
end
execute "ALTER TABLE AZ_TITLE ADD PRIMARY KEY (AZ_TITLE_ID);"

create_table "AZ_EXTRA_INFO", {:id => false} do |t|
t.integer "AZ_EXTRA_INFO_ID", :default => 0, :null => false
t.string "AZ_PROFILE", :limit => 100, :null => false
t.integer "OBJECT_ID", :default => 0, :null => false, :limit => 8
t.text "EXTRA_INFO_XML", :limit => 16777215
end
execute "ALTER TABLE AZ_EXTRA_INFO ADD PRIMARY KEY (AZ_EXTRA_INFO_ID);"

create_table "AZ_TITLE_SEARCH", {:id => false} do |t|
t.integer "AZ_TITLE_SEARCH_ID", :default => 0, :null => false
t.string "AZ_PROFILE", :limit => 100, :null => false
t.integer "AZ_TITLE_ID", :default => 0, :null => false
t.text "TITLE_SEARCH", :null => false
end
execute "ALTER TABLE AZ_TITLE_SEARCH ADD PRIMARY KEY (AZ_TITLE_SEARCH_ID);"

create_table "AZ_LETTER_GROUP", {:id => false} do |t|
t.integer "AZ_LETTER_GROUP_ID", :default => 0, :null => false
t.integer "AZ_TITLE_ID", :default => 0, :null => false
t.string "AZ_LETTER_GROUP_NAME", :limit => 10, :null => false
end
execute "ALTER TABLE AZ_LETTER_GROUP ADD PRIMARY KEY (AZ_LETTER_GROUP_ID);"
else
puts "Skipping SFX DB migration since the SFX DB specified is not a mock instance."
end
end

def sfx4_mock_instance?
(ActiveRecord::Base.configurations["sfx_db"] and
ActiveRecord::Base.configurations["sfx_db"]["mock_instance"])
end
end
5 changes: 4 additions & 1 deletion test/dummy/db/migrate/README
Expand Up @@ -4,4 +4,7 @@ _not_ included here in this test/dummy app used for testing.
In a Rails plugin gem, Rails db:migrate seems to be able to use
the migrations from the actual gem itself, in the gem source
./db/migrate, and if they are doubly included here, we get
duplicate migration errors trying to db:migrate.
duplicate migration errors trying to db:migrate.

We do have one migration in here, to create the mock SFX database for testing,
something an ordinary real Umlaut app does not do.

0 comments on commit b584fb7

Please sign in to comment.