我已经更新了rails,spree(电子商务框架),并添加了一些新的gems。这些都需要在更新和安装之后迁移。在开发应用程序上,我遇到了一个问题。每当我试图迁移时,都会出错
问题
activeRecord::statementInvalid:pg::DuplicateTable:error:relation“index_products_promotion_rules_on_product_id”已存在
:在“spree-products-promotion-rules”上创建索引“index-products-promotion-rules-on-product-id”(“product-id”)。
当我尝试将我的网站部署到实时服务器时,错误/问题将返回,
我已经尝试从
migration file
schema.rb
是否保存以从
还是有其他方法来解决这个问题?
create_table "spree_product_promotion_rules", force: :cascade do |t|
t.integer "product_id"
t.integer "promotion_rule_id"
t.index ["product_id"], name: "index_products_promotion_rules_on_product_id"
t.index ["promotion_rule_id", "product_id"], name: "index_products_promotion_rules_on_promotion_rule_and_product"
迁移文件
# This migration comes from spree (originally 20120831092359)
class SpreePromoOneTwo < ActiveRecord::Migration[4.2]
def up
# This migration is just a compressed migration for all previous versions of spree_promo
return if table_exists?(:spree_products_promotion_rules)
create_table :spree_products_promotion_rules, :id => false, :force => true do |t|
t.references :product
t.references :promotion_rule
end
add_index :spree_products_promotion_rules, [:product_id], :name => 'index_products_promotion_rules_on_product_id'
add_index :spree_products_promotion_rules, [:promotion_rule_id], :name => 'index_products_promotion_rules_on_promotion_rule_id'
create_table :spree_promotion_actions, force: true do |t|
t.references :activator
t.integer :position
t.string :type
end
create_table :spree_promotion_rules, force: true do |t|
t.references :activator
t.references :user
t.references :product_group
t.string :type
t.timestamps null: false
end
add_index :spree_promotion_rules, [:product_group_id], name: 'index_promotion_rules_on_product_group_id'
add_index :spree_promotion_rules, [:user_id], name: 'index_promotion_rules_on_user_id'
create_table :spree_promotion_rules_users, id: false, force: true do |t|
t.references :user
t.references :promotion_rule
end
add_index :spree_promotion_rules_users, [:promotion_rule_id], name: 'index_promotion_rules_users_on_promotion_rule_id'
add_index :spree_promotion_rules_users, [:user_id], name: 'index_promotion_rules_users_on_user_id'
end
end