【问题标题】:Postgresql and devise db migrate failurePostgresql 和设计数据库迁移失败
【发布时间】:2014-08-12 05:42:03
【问题描述】:

在使用 devise gem 时,无法使用 postgresql 迁移 db。

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment 
** Invoke db:load_config 
** Execute db:schema:dump 

rake db:migrate:status 不返回任何内容:

database: sampleapp_development

 Status   Migration ID    Migration Name
--------------------------------------------------

如果我执行rails g scaffold <WHATEVER> name email 并运行 rake db:migrate 一切正常,但使用设计...什么都没有。

宝石文件:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'bootstrap-generators', '~> 3.1.1'
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass', '~> 3.1.1'

gem 'simple_form'

gem 'rails_12factor', group: :production

gem 'devise'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',     group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

【问题讨论】:

  • 你能看到生成的设计迁移文件吗?
  • @nidhi 是的,我是。我可以看到所有的迁移文件20140621182346_devise_create_users
  • 这很奇怪.. 你可以尝试删除数据库并再次运行所有迁移
  • 我已经这样做了。我不知道为什么这也不起作用..即将回到mysql
  • 嘿,你能检查一下你的迁移文件名吗?有人在这里发布了类似的问题ruby-forum.com/topic/4496102

标签: ruby-on-rails postgresql devise rake


【解决方案1】:

请检查 Devise 生成的迁移文件。有时它会生成一个带有 txt 扩展名的文件,该文件不会运行您的迁移。

需要用 rb 扩展名重命名文件才能正常工作。

【讨论】:

    猜你喜欢
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2018-04-06
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    相关资源
    最近更新 更多