Rails - Postgres数据库不使用迁移更新新列(Rails 5)

时间:2017-05-19 12:45:45

标签: ruby-on-rails database postgresql migration ruby-on-rails-5

Rails 5.0.0.1 到目前为止,我已经在这个rails应用程序上完成了一百万次迁移,并且没有任何问题。突然之间,最后2个,他们没有更新数据库,我无法弄清楚原因。一切似乎都在说它正在更新数据库 - 迁移似乎正在运行,我没有收到任何错误消息。

这是第一个:

(20170517040333_add_shiptime_to_supplier_specifics)

class AddShiptimeToSupplierSpecifics < ActiveRecord::Migration[5.0]
  def change
    add_column :supplier_specifics, :shiptime, :string
  end
end

我的供应商特定型号(supplier_specific.rb):

class SupplierSpecific < ApplicationRecord
    has_many :images, dependent: :destroy
    belongs_to :supplier
    belongs_to :item

end

bundle exec rake:db dropbundle exec rake:db createbundle exec rake:db migrate之后,我最终获得了此输出:

== 20170517040333 AddShiptimeToSupplierSpecifics: migrating ===================
-- add_column(:supplier_specifics, :shiptime, :string)
   -> 0.0581s
== 20170517040333 AddShiptimeToSupplierSpecifics: migrated (0.0587s) ==========

我的Schema.rb显示:

create_table "supplier_specifics", force: :cascade do |t|
    t.money    "price",                scale: 2
    t.integer  "quantity"
    t.money    "shipping_cost",        scale: 2
    t.string   "link"
    t.string   "status"
    t.integer  "item_id"
    t.integer  "supplier_id"
    t.datetime "created_at",                     null: false
    t.datetime "updated_at",                     null: false
    t.money    "priceUpdateIndicator", scale: 2
    t.integer  "inStock"
    t.string   "shiptime"
    t.index ["item_id"], name: "index_supplier_specifics_on_item_id", using: :btree
    t.index ["supplier_id"], name: "index_supplier_specifics_on_supplier_id", using: :btree
  end

我甚至将该项目列入白名单(不是它应该重要,对吗?):

# Never trust parameters from the scary internet, only allow the white list through.
def supplier_specific_params
  params.require(:supplier_specific).permit(:price, :quantity, :shipping_cost, :shiptime, :link, :status, :inStock)
end

现在我进入Postgres(psql,使用绝对正确的数据库)并描述supplier_specifics表:

Table "public.supplier_specifics"
Column | Type | Modifiers | Storage  | Stats target | Description 
----------------------------------------+----------+--------------+--------
 id  | integer   | not null default nextval('supplier_specifics_id_seq'::regclass) | plain    |  | 
 price | money | | plain    |  | 
 quantity  | integer  | | plain    |  | 
 shipping_cost   | money  | | plain    |  | 
 link  | character varying  | | extended |  | 
 status  | character varying  | | extended |  | 
 created_at  | timestamp without time zone | not null  | plain    |  | 
 updated_at  | timestamp without time zone | not null | plain    |  | 
 item_id | integer  | | plain    |  | 
 supplier_id  | integer  | | plain    |  | 
 priceUpdateIndicator | money  |  | plain    |   | 
 inStock  | integer  |   | plain    |   | 
Indexes:
    "supplier_specifics_pkey" PRIMARY KEY, btree (id)
    "index_supplier_specifics_on_item_id" btree (item_id)
    "index_supplier_specifics_on_supplier_id" btree (supplier_id)
Foreign-key constraints:
    "fk_rails_2f4080469a" FOREIGN KEY (supplier_id) REFERENCES suppliers(id)
    "fk_rails_6a06cdf3af" FOREIGN KEY (item_id) REFERENCES items(id)
Has OIDs: no

如您所见,数据库中没有新列。

如果我需要提供任何可以让某人理解的东西,请告诉我。谢谢,世界。

0 个答案:

没有答案