迁移未运行

时间:2016-09-04 01:35:26

标签: ruby-on-rails

  
    

嘿伙计们,我想在我的工作中添加twitter-oauth功能。我已经安装了“omniauth-twitter”宝石。当我尝试运行迁移时,这是错误消息

  
C:\Sites\omniauth-tutorial>rake db:migrate
== 20160904075837 CreateUsers: migrating      ======================================
-- create_table(:users)
-- add_index(:users, :provider)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: no such table: main.users: CREATE  INDEX "index_users_on_
provider" ON "users" ("provider")
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:10:in `block in change'
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:3:in `change'
C:in `migrate' ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: 
main.users: CREATE  INDEX "index_users_on_provider" ON "users"("provider")
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:10:in `block in change'
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:3:in `change'
C:in `migrate'
SQLite3::SQLException: no such table: main.users
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:10:in `block in change'
C:/Sites/omniauth-tutorial/db/migrate/20160904075837_create_users.rb:3:in `change'
C:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
  
    

这是我的迁移文件

  
class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :provider, null: false
      t.string :uid, null: false
      t.string :name
      t.string :location
      t.string :image_url
      t.string :url
      add_index :users, :provider
      add_index :users, :uid
      add_index :users, [:provider, :uid], unique: true

      t.timestamps null: false
    end
  end
end
  
    

请问如何解决这个问题???

  

1 个答案:

答案 0 :(得分:2)

您需要将$ awk -F' *, *' 'split($2,t,/ */)>3' file 1999, random strings go here, £50.00, 983903893 1945, North Wales is the Adrenaline Capital of Europe, £78.99, 83983 命令放在add_index

之后
create_table