How do you skip failed migrations? (rake db:migrate)

前端 未结 7 1680
忘了有多久
忘了有多久 2021-01-30 16:32

I can\'t seem to find an option or anything that allows me to skip migrations.

I know what you\'re thinking: \"you should never have to do that...\"

I need to sk

7条回答
  •  无人及你
    2021-01-30 17:27

    I had an issue where I had a migration to add a table that already existed, so in my case I had to skip this migration as well, because I was getting the error

    SQLite3::SQLException: table "posts" already exists: CREATE TABLE "posts"
    

    I simply commented out the content of the create table method, ran the migration, and then uncommented it out. It's kind of a manual way to get around it, but it worked. See below:

    class CreatePosts < ActiveRecord::Migration
      def change
        # create_table :posts do |t|
        #   t.string :title
        #   t.text :message
        #   t.string :attachment
        #   t.integer :user_id
        #   t.boolean :comment
        #   t.integer :phase_id
    
        #   t.timestamps
        # end
      end
    end
    

提交回复
热议问题