如何使用模式配置使用 postgresql 的 Heroku 应用程序的数据库?
我一直在使用mysql。从来没有真正需要过任何更奇特的东西。但我经常使用heroku,在工作时,我喜欢免费搜索,所以我使用acts_as_tsearch 插件。如果您访问 git 存储库,它会告诉您:
* Preparing your PostgreSQL database
Add a text search configuration 'default':
CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english )
那么您猜怎么着?我
- 在rails配置中从mysql更改为postgresql,
- 在pgAdmin(postgres的gui)的sql痛苦中运行“CREATE TEXT”代码,
- 注意到现在我的开发数据库有一个称为“FTS配置”的东西
- 尝试了搜索功能并且它有效太棒了
,但是我无法将该配置显示在架构中。当我执行 rake db:dump 时,它没有出现在那里。我知道我可以将这一行添加到 schema.rb:
execute 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english )'
中,这样就可以了,但是如何才能将该配置添加到架构中而无需手动添加它呢?当有人输入 rake db:load 时,我可以创建一个在 schema.rb 之后加载的文件吗?
对于 postgres 的人来说,有一个问题:CREATE TEXT SEARCH CONFIGURATION... 有什么作用?
I've been using mysql forever. never really needed anything fancier. But I'm using heroku a lot and while I'm working, I like free search, so I'm using the acts_as_tsearch plugin. If you go to the git repository, it tells you:
* Preparing your PostgreSQL database
Add a text search configuration 'default':
CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english )
So guess what? I
- changed from mysql to postgresql in my rails config
- ran that "CREATE TEXT" code in the sql pain of pgAdmin (a gui for postgres)
- noticed that now my development DB has something called an "FTS configuration"
- tried the search functionality and it works GREAT
But I'm having trouble getting that configuration to show up in the schema. When I did rake db:dump it doesn't make it in there. I know I can add this line to the schema.rb:
execute 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english )'
and that works, but how can I get that configuration into the schema without my having to hand-add it? Can I create a file that is also loaded after schema.rb when someone types rake db:load?
And for the postgres people, a question: What does that CREATE TEXT SEARCH CONFIGURATION... do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不尝试将其添加到迁移文件中并将其与heroku 数据库进行比较?
Why don't you try adding it to a migration file and rake that against the heroku db?