Skip to content
This repository
Browse code

Made Oracle a first-class connection adapter by adhering closer to id…

…iomatic Oracle style #1798 [The Gang of Oracles]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1913 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 852e5a435de6413785b21fdbf6ba6175a0bc09f3 1 parent 14ea312
David Heinemeier Hansson authored July 24, 2005

Showing 1 changed file with 12 additions and 2 deletions. Show diff stats Hide diff stats

  1. 14  railties/fresh_rakefile
14  railties/fresh_rakefile
@@ -137,6 +137,11 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
137 137
       `#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
138 138
     when "sqlserver"
139 139
       `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
  140
+    when "oci", 
  141
+      ActiveRecord::Base.establish_connection(:test)
  142
+      IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
  143
+        ActiveRecord::Base.connection.execute(ddl)
  144
+      end
140 145
     else 
141 146
       raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
142 147
   end
@@ -146,7 +151,7 @@ desc "Dump the database structure to a SQL file"
146 151
 task :db_structure_dump => :environment do
147 152
   abcs = ActiveRecord::Base.configurations
148 153
   case abcs[RAILS_ENV]["adapter"] 
149  
-    when "mysql"
  154
+    when "mysql", "oci"
150 155
       ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
151 156
       File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
152 157
     when "postgresql"
@@ -183,7 +188,12 @@ task :purge_test_database => :environment do
183 188
       dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
184 189
       `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
185 190
       `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
186  
-    else 
  191
+    when "oci"
  192
+      ActiveRecord::Base.establish_connection(:test)
  193
+      ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
  194
+        ActiveRecord::Base.connection.execute(ddl)
  195
+      end
  196
+    else
187 197
       raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
188 198
   end
189 199
 end

0 notes on commit 852e5a4

Please sign in to comment.
Something went wrong with that request. Please try again.