如何在创建数据库时安装Postgres扩展? [英] How to install Postgres extensions at database creation?
本文介绍了如何在创建数据库时安装Postgres扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果rake命令 db:create
后面可以有一个postgresql安装脚本,那将是很可爱的。例如。 (必须以postgres用户身份运行):
创建扩展名 fuzzystrmatch;
这是因为在此刻,我每次创建数据库时都要手动进行操作。 / p>
有任何提示吗?
解决方案
从Rails 4开始, enable_extension
方法:
class AddFuzzyStringMatching< ActiveRecord :: Migration
def change
enable_extension fuzzystrmatch
结束
结束
It would be lovely if the rake command db:create
could be followed by a postgresql installation script. This, for example. (It must be run as postgres user):
CREATE EXTENSION "fuzzystrmatch";
This because, in this moment, i'm doing it manually every time I create a database.
Any hints?
解决方案
As of Rails 4, there is a enable_extension
method:
class AddFuzzyStringMatching < ActiveRecord::Migration
def change
enable_extension "fuzzystrmatch"
end
end
这篇关于如何在创建数据库时安装Postgres扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文