【问题标题】:ActiveRecord Migration活动记录迁移
【发布时间】:2015-10-06 11:14:23
【问题描述】:

我之前通过主动迁移设置了数据库。但是,当我在另一个项目上设置一个新项目时,它似乎不正确。 我在命令行中输入这个

bin/rails generate migration Database Date:date Endpoint:text User:string Domain:string 

但是输出是这样的(为了简洁,sn-p):

Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub rails` to work around a system/bundle conflict.
Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]                                      # Path to the Ruby binary of your choice
                                                         # Default: /Users/alexbozanic/.rvm/rubies/ruby-2.2.1/bin/ruby
  -m, [--template=TEMPLATE]                              # Path to some application template (can be a filesystem path or URL)
      [--skip-gemfile], [--no-skip-gemfile]              # Don't create a Gemfile
  -B, [--skip-bundle], [--no-skip-bundle]                # Don't run bundle install
  -G, [--skip-git], [--no-skip-git]                      # Skip .gitignore file
      [--skip-keeps], [--no-skip-keeps]                  # Skip source control .keep files
  -O, [--skip-active-record], [--no-skip-active-record]  # Skip Active Record files
  -S, [--skip-sprockets], [--no-skip-sprockets]          # Skip Sprockets files
      [--skip-spring], [--no-skip-spring]                # Don't install Spring application preloader
  -d, [--database=DATABASE]                              # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                                         # Default: sqlite3
  -j, [--javascript=JAVASCRIPT]                          # Preconfigure for selected JavaScript library
                                                         # Default: jquery
  -J, [--skip-javascript], [--no-skip-javascript]        # Skip JavaScript files
      [--dev], [--no-dev]                                # Setup the application with Gemfile pointing to your Rails checkout
      [--edge], [--no-edge]                              # Setup the application with Gemfile pointing to Rails repository
      [--skip-turbolinks], [--no-skip-turbolinks]        # Skip turbolinks gem
  -T, [--skip-test-unit], [--no-skip-test-unit]          # Skip Test::Unit files
      [--rc=RC]                                          # Path to file containing extra configuration options for rails command
      [--no-rc], [--no-no-rc]                            # Skip loading of extra configuration options from .railsrc file

发生了什么事?谢谢

【问题讨论】:

  • 此解决方案是否有效stackoverflow.com/a/23658355/5076451
  • 我敢打赌Database 是一个保留字,所以你不能将它用作模型/迁移名称。换成别的,应该就好了。

标签: ruby-on-rails activerecord database-migration


【解决方案1】:

我最终使用 bin/rails generate (model) 而不是 migrate,它似乎工作得很好!这是一个适当的解决方案吗?或者两者之间有显着差异吗?谢谢!

【讨论】:

    【解决方案2】:

    听起来您可能需要重新生成 binstub。尝试运行:

    rake rails:update:bin
    

    【讨论】:

    • 感谢您的快速回复!运行 rake rails:update:bin 后成功创建文件 e.g 0002020338_database.rb
    • 这是输出: bin/rails generate migration Database Date:date Endpoint:text User:string Domain:string invoke active_record create db/migrate/20150716204130_database.rb 为什么它没有创建所有rb 迁移文件中的列?
    • 也许大写字母把它扔掉了。尝试全部小写
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 2013-07-27
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 2016-03-01
    • 2014-06-15
    相关资源
    最近更新 更多