当我尝试创建一个数据库时,我会得到下面的错误。下面是database.yml:
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
adapter: postgresql
encoding: unicode
database: MyDatabase
host: localhost
pool: 5
username: name
password: name`
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test. postgresql
production:
adapter: postgresql
encoding: unicode
database: MyDatabase_Production
host: localhost
pool: 5
username: name
password: name
role: MyRole以下是错误:
Database 'MyDatabase' already exists
PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Couldn't create 'db/test. postgresql' database. Please check your configuration.
rails aborted!
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Caused by:
PG::SyntaxError: ERROR: syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"." postgresql" ENCODING = 'utf8'
^
Tasks: TOP => db:create
(See full trace by running task with --trace)当我运行rails db:创建posgresql数据库时,我得到了上面的错误
发布于 2022-11-20 21:20:51
看起来您的一些文本配置可能被删除了。应该是这样的:
test:
<<: *default
database: test
username: name
password: name发布于 2022-11-20 23:22:11
正如错误中所述,数据库配置中存在语法错误。
<<: *default
database: db/test. postgresql有一个不允许的点和空格。将其重命名为其他东西将解决问题。示例:
<<: *default
database: db/test_postgresqlhttps://stackoverflow.com/questions/74506894
复制相似问题