"SQLite3 :: SQLException: no such table: main.category" running rake db: migrate with Gem Acestry

1

I'm having trouble using the gem Acestry in the part where it says:

  

Add index to migration: add_index [table],: ancestry (UP) / remove_index [table],: ancestry

I'm creating a method called Category and trying to add Acestry but the following error appears in PowerShell:

  

== AddAncestryToCategory: migrating ==========================================================   - add_column (: categories,: ancestry,: string)      - > 0.0140s   - add_index (: category,: ancestry)   rake aborted!   An error has occurred, this and all later migrations canceled:

     SQLite3 :: SQLException: no such table: main.category: CREATE INDEX "index_category_on_ancestry" ON "category" ("ancestry   ") C: /Sites/projects/mymoney/db/migrate/20140205153511_add_ancestry_to_category.rb: 4: in change' C:in migrate '   Tasks: TOP = > db: migrate   (See full trace by running task with --trace)

Follow the migration code:

class CreateCategories < ActiveRecord::Migration
  def change
    create_table :categories do |t|
      t.string :name

      t.timestamps
    end
  end
end

E

class AddAncestryToCategory < ActiveRecord::Migration
  def change
    add_column :categories, :ancestry, :string
    add_index :category, :ancestry
  end
end
    
asked by anonymous 05.02.2014 / 17:04

1 answer

0

According to the add_index documentation, link Home The table name is passed in the plural, so I think if you change the example to add_index :categories, :ancestry , it will work normally.

    
05.02.2014 / 18:50