简体   繁体   English

Ruby on Rails Foreigner插件不适用于SQL Server

[英]Ruby on Rails Foreigner plugin not working for SQL Server

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. 好了,既然我终于配置了愚蠢的ODBC内容,我就从一个Postgres数据库中转储了一个schema.rb文件,并在为SQL Server配置的Rails项目中对其进行了db:schema:load

Well, it sets up all the schema in the SQL Server database except for a minor detail: No foreign keys are created. 好吧,它设置了SQL Server数据库中的所有架构,除了一个小细节:没有创建外键。

The rake command doesn't show any errors and does say it is adding foreign keys. rake命令没有显示任何错误,并且确实说它正在添加外键。 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? 外国人插件在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) 外国人实际上并没有内置对SQL Server的支持,但它与SQL_2003足够接近,可以正常工作(减去删除外键并检测架构)

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). 在博客上发表了一篇关于它的文章 ,基本上归结为在适配器列表中添加,并为SQL Server创建了一个非常简单的新适配器(使用PostgreSQL适配器作为模板)。 (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 同时,您可以使用我的存储库中的版本: https : //github.com/cjheath/foreigner

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM