문제

Well, now that I've finally got my stupid ODBC stuff configured, I took a schema.rb file that I dumped from a Postgres database and did a db:schema:load on it in a Rails project configured for SQL Server.

Well, it sets up all the schema in the SQL Server database except for a minor detail: No foreign keys are created.

The rake command doesn't show any errors and does say it is adding foreign keys. But they don't actually get added. This is the last bit from the command:

-- add_foreign_key("workhistoryform", "form", {:name=>"workhistoryform_form_rid_fkey", :column=>"form_rid", :primary_key=>"form_rid"})
   -> 0.0002s
-- initialize_schema_migrations_table()
   -> 0.0092s
-- assume_migrated_upto_version(0)
   -> 0.0942s
[earlz@earlzarch avp_msql_migrations]$

So what is the problem? Does the Foreigner plugin not work in SQL Server? If it didn't I'd expect to see an error or something...

도움이 되었습니까?

해결책

Ok, I fixed it. Well, hacked it anyway. Foreigner doesn't actually have built in support for SQL Server, but it is close enough to SQL_2003 that it works (minus removing Foreign Keys and detecting the Schema)

I made a post about it on my blog which basically boiled down to adding a to the list of adapters and creating a very simple new adapter for SQL Server(use the PostgreSQL adapter as a template). (modifying the Foreigner gem)

다른 팁

I fixed this properly and sent a pull request to foreigner's author. Meantime, you can use the version from my repository: https://github.com/cjheath/foreigner

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top