PG :: UndefinedTable:错误:关系“用户”不存在-Azure数据库

时间:2019-04-01 22:26:49

标签: ruby-on-rails azure devise

在Azure(通过Linux虚拟机)上部署Web应用程序后,我成功访问了首页(第一页),但是当我尝试登录时(导航栏的右上角)出现此错误:

Error

我查了一下这个问题,发现其他人也遇到了。他们通过重置和迁移解决了该问题,但是它不起作用。 到目前为止,我已经尝试过:

  1. 以下命令可以正确执行,但不能解决问题:

    RAILS_ENV=production rake db:drop db:create db:migrate

  2. 注释掉user.rb文件,但不能解决问题

我认为错误是由于宝石devise或宝石rails_admin引起的,但是我无法解决该问题。

宝石文件:

source 'https://rubygems.org'

ruby '2.6.0'

gem 'grape'

gem 'bootsnap', require: false

gem 'devise'

gem 'jbuilder', '~> 2.0'

gem 'pg', '~> 0.21'

gem 'puma'

gem 'rails', '5.2.2'

gem 'redis'

gem "mini_magick"

gem "chartkick"

gem 'country-select'

gem 'rails_admin', '~> 1.3'

gem 'activestorage-validator'

gem 'rubyzip', '>= 1.2.1'

gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'c8ac844'

gem 'axlsx_rails'

gem 'autoprefixer-rails'

gem 'bootstrap-sass', '~> 3.3'

gem 'font-awesome-sass', '~> 5.5.0'

gem 'sassc-rails'

gem 'simple_form'

gem 'uglifier'

gem 'webpacker'

group :development do

gem 'web-console', '>= 3.3.0'

end

group :development, :test do

gem 'pry-byebug'

gem 'pry-rails'

gem 'listen', '~> 3.0.5'

gem 'spring'

gem 'spring-watcher-listen', '~> 2.0.0'

gem 'dotenv-rails'

end

database.yml 的内容:

default: &default
    adapter: postgresql
    encoding: utf-8
    database: caoee
    username: mat
    password: ***
    pool: 5
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
    <<: *default
    adapter: postgresql
    encoding: utf-8
    database: caoee
    username: mat
    password: ***
    pool: 5

test:
    <<: *default
    adapter: postgresql
    encoding: utf-8
    database: caoee
    username: mat
    password: ***
    pool: 5

production:
    adapter: postgresql
    encoding: utf-8
    database: caoee
    username: mat
    password: ***
    pool: 5

Postgresql角色:

角色列表

Role name | Attributes | Member of
-----------------------------------    
mat | Superuser, Create role, Create DB | {}

postgres | Superuser, Create role, Create DB, Replication, Bypass RLS|{}

1 个答案:

答案 0 :(得分:0)

您是否在本地运行该命令RAILS_ENV=production ...? 因为那将只在本地使用生产设置运行命令。

您需要在Azure服务器上重置数据库。我不熟悉Azure CLI,但是我确定有命令可以远程重置数据库。