使用PostgreSQL运行Rails数据库迁移的最低权限 [英] Minimum privileges to run a rails db migration with PostgreSQL

查看:85
本文介绍了使用PostgreSQL运行Rails数据库迁移的最低权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参加了一个网络托管计划,因此可以发布我的Rails应用程序。他们为我提供了服务器并可以访问它。这是一台共享的CentOS Linux服务器,我可以访问它的bash。

I enrolled into a web-host plan so I could have my rails apps published. They provided me with a server and access to it. This is a shared CentOS Linux server and I can access its bash.

我试图将数据库模式加载到他们提供的postgres数据库(v8.4)中,但是这样做给我一个错误。
执行时:

I was trying to load my database schema into the postgres database (v8.4) they are offering but it gives me an error when doing so. When I execute:

 RAILS_ENV=production rake db:schema:load

会生成以下错误:

-- enable_extension("plpgsql")
rake aborted!
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near "EXTENSION"
LINE 1: CREATE EXTENSION IF NOT EXISTS "plpgsql"
               ^
: CREATE EXTENSION IF NOT EXISTS "plpgsql"
/home/user/path-to-app/db/schema.rb:17:in `block in <top (required)>'
/home/user/path-to-app/db/schema.rb:14:in `<top (required)>'
PG::SyntaxError: ERROR:  syntax error at or near "EXTENSION"
LINE 1: CREATE EXTENSION IF NOT EXISTS "plpgsql"
               ^
/home/user/path-to-app/db/schema.rb:17:in `block in <top (required)>'
/home/user/path-to-app/db/schema.rb:14:in `<top (required)>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)

因为Web主机提供程序不允许许多数据库特权,并且由于我不熟悉PostgreSQL,所以我希望有一个解决方案来改变某些问题……

Because the web-host provider does not allow many db privileges, and due to my unfamiliarity with PostgreSQL, I would prefer a solution changing something on the rails side...

我可以在铁轨方面做一些事情来解决(或希望解决)这个问题吗?

Is there something I can do on the rails side to work around (or hopefully address) this issue?

如果在铁轨方面真的无法做任何事情,我将不得不

If nothing can be really done from the rails side I would have to be specific with the privileges necessary.

此PostgreSQL EXTENSION对象似乎要求我的数据库用户没有权限...

This PostgreSQL EXTENSION object seems to demand privileges my db user does not have...

Rails数据库用户在PostgeSQL中运行数据库迁移?

What would be the minimum privileges for the rails database user running the db migration in PostgeSQL?

这是关于PostgreSQL 8.4的,根据这里的评论,没有 CREATE EXTENSION

This is about PostgreSQL 8.4, witch according to the comments here do not have the "CREATE EXTENSION" command.

推荐答案

创建扩展在Postgres 9.1中引入,建议您运行迁移:

CREATE EXTENSION was introduced with Postgres 9.1, i suggest you to run migrations:

RAILS_ENV=production bundle exec rake db:migrate

这篇关于使用PostgreSQL运行Rails数据库迁移的最低权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆