Skip to content
This repository
Browse code

Add build/drop/rebuild tasks for SQL Server. Closes #9588 [lawrence]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7894 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5d3e72486b94f8fcc14a01fdf397d3f865759357 1 parent 86a9c21
Jeremy Kemper authored October 15, 2007

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

  1. 35  activerecord/Rakefile
35  activerecord/Rakefile
@@ -66,7 +66,7 @@ end
66 66
 
67 67
 task :build_mysql_databases => 'mysql:build_databases'
68 68
 task :drop_mysql_databases => 'mysql:drop_databases'
69  
-task :rebuild_mysql_databases => [:drop_mysql_databases, :build_mysql_databases]
  69
+task :rebuild_mysql_databases => 'mysql:rebuild_databases'
70 70
 
71 71
 
72 72
 namespace :postgresql do
@@ -90,7 +90,7 @@ end
90 90
 
91 91
 task :build_postgresql_databases => 'postgresql:build_databases'
92 92
 task :drop_postgresql_databases => 'postgresql:drop_databases'
93  
-task :rebuild_postgresql_databases => [:drop_postgresql_databases, :build_postgresql_databases]
  93
+task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
94 94
 
95 95
 
96 96
 namespace :frontbase do
@@ -138,6 +138,37 @@ task :build_frontbase_databases => 'frontbase:build_databases'
138 138
 task :rebuild_frontbase_databases => 'frontbase:rebuild_databases'
139 139
 
140 140
 
  141
+namespace :sqlserver do
  142
+  desc 'Build the SQL Server test databases'
  143
+  task :build_databases do
  144
+    # Define a user named 'rails' in SQL Server with all privileges granted
  145
+    # Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
  146
+    # which allows you to set a default password for the current session.
  147
+    %x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P )
  148
+    %x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P )
  149
+    %x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P )
  150
+    %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P )
  151
+    %x( osql -S localhost -U rails -d activerecord_unittest -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
  152
+    %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
  153
+    %x( osql -S localhost -U rails -d activerecord_unittest -i #{File.join(SCHEMA_PATH, 'sqlserver.sql')} -n -P )
  154
+    %x( osql -S localhost -U rails -d activerecord_unittest2 -i #{File.join(SCHEMA_PATH, 'sqlserver2.sql')} -n -P )
  155
+  end
  156
+
  157
+  desc 'Drop the SQL Server test databases'
  158
+  task :drop_databases do
  159
+    %x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P )
  160
+    %x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P )
  161
+  end
  162
+
  163
+  desc 'Rebuild the SQL Server test databases'
  164
+  task :rebuild_databases => [:drop_databases, :build_databases]
  165
+end
  166
+
  167
+task :build_sqlserver_databases => 'sqlserver:build_databases'
  168
+task :drop_sqlserver_databases => 'sqlserver:drop_databases'
  169
+task :rebuild_sqlserver_databases => 'sqlserver:rebuild_databases'
  170
+
  171
+
141 172
 # Generate the RDoc documentation
142 173
 
143 174
 Rake::RDocTask.new { |rdoc|

0 notes on commit 5d3e724

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