I am working on Rails 3 project where I initially used MySQL as RDBMS. But later my client requested that we should use MSSQL. After spending half a day, I am able to connect with the MSSQL server using the article here: http://oldwiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnLinux
But after all the effort, when I tried to migrate, I got following error:
Here is error with rake db:migrate
== CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, all later migrations canceled:
37000 (2715) [unixODBC][FreeTDS][SQL Server]Column, parameter, or variable #1: Cannot find data type primary_key.
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
When I re-run the same command, I get the error:
rake aborted!
S0001 (2714) [unixODBC][FreeTDS][SQL Server]There is already an object named 'schema_migrations' in the database.
- which means atleast connection is working!
Following is the error with rake db:schema:load
-- create_table("banners", {:force=>true})
rake aborted!
37000 (2715) [unixODBC][FreeTDS][SQL Server]Column, parameter, or variable #1: Cannot find data type primary_key.
I googled for the error but could not find any help, it seems its not a popular combination.
I am at present looking at this problem in two ways:
try to solve the problem in hand, by making rails 开发者_运维百科output SQL in MSSQL friendly format. And if the first one fails then
as a workaround, convert the raw mysql dump to MSSQL format.
As I got no answers, I went with a solution close to #2 above. I created the database tables one by one by using MSSQL import and export wizard by connecting it through a MySQL DSN. I am still looking for a way to do this is pure rails way, because every time I change any models, I have to manually update the MSSQL database.
精彩评论