I am trying to set up Rails tests with MS SQL server. Currently Rails is working just fine with the normal development environment environment on the same SQL server instance.
I initially tried by manually creating a database with the same login as I used for development attached to it called PRODUCT_TEST. Database created fine.
when I ran rake db:test:prepare I got this
C:\Code\git.product>rake db:test:prepare
rake aborted!
ActiveRecord::JDBCError: CREATE DATABASE permission denied in database 'master'.: CREATE DATABASE PRODUCT_TEST
so it looks like it drops and recreates the DB.
I added the user to all of the roles of the DB server and tries again and got this.
C:\Code\git.product>rake db:test:prepare --trace
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
rake aborted!
The driver encountered an unknown error: Cannot open database "PRODUCT_TEST" requested by the login. The login failed.
C:/Program Files/jruby-1.7.0.preview1/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-e49ec53fb369/lib/arjdbc/jdbc/connection.rb:91:in `initialize'
C:/Program Files/jruby-1.7.0.preview1/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-e49ec53fb369/lib/arjdbc/jdbc/adapter.rb:33:in `initialize'
The database no longer exists and has been dropped. I tried this with both the user I created and the ‘sa’ user and neither work. I am able to connect to the database server and my development database using either just fine, both in enterprise manager and rails.
The database.yml looks like this
test:
adapter: jdbcmssql
username: sa
password: password
host: 127.0.0.1
database: PRODUCT_TEST
Any idea what I am doing wrong?
Thanks.
Note: using Rails 3.2.3, JRuby 1.7.0.preview, Microsoft SQL Server Express Edition (64-bit) 10.50.1617.0
Fixed: I recreated the PRODUCT_TEST database manually and and assigned the account as the owner. This time the tool did not drop the database and was able to access it correctly