Skip to content

Commit

Permalink
Update migrations that reference models by reseting the column inform…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
joshcano authored and seanmarcia committed Jun 26, 2018
1 parent d448369 commit 4276198
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
1 change: 1 addition & 0 deletions db/migrate/20160622003120_adds_counter_cache_to_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def up
Item.unscoped.all.each { |item|
Item.unscoped.reset_counters(item.id, :barcode_items)
}
Item.reset_column_information
end
def down
remove_column :items, :barcode_count
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170603022915_adds_issued_at_to_donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def up
d.issued_at = d.created_at
d.save
end
Donation.reset_column_information
end

def down
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170622195729_add_issued_at_to_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def up
d.issued_at = d.created_at
d.save
end
Distribution.reset_column_information
end

def down
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170923232659_add_name_to_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def up
u.update_attributes(name: new_name)
puts "Updated #{u.email} with #{u.name}"
end
User.reset_column_information
end

def down
Expand Down
2 changes: 2 additions & 0 deletions db/migrate/20180607144046_initialize_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ def up
ci.category = "Miscellaneous"
end
Item.where(canonical_item_id: nil).update_all(canonical_item_id: ci.id)
CanonicalItem.reset_column_information
Item.reset_column_information
end

def down
Expand Down
56 changes: 28 additions & 28 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end

create_table "adjustments", force: :cascade do |t|
create_table "adjustments", id: :serial, force: :cascade do |t|
t.integer "organization_id"
t.integer "storage_location_id"
t.text "comment"
Expand All @@ -46,7 +46,7 @@
t.index ["storage_location_id"], name: "index_adjustments_on_storage_location_id"
end

create_table "barcode_items", force: :cascade do |t|
create_table "barcode_items", id: :serial, force: :cascade do |t|
t.string "value"
t.integer "barcodeable_id"
t.integer "quantity"
Expand All @@ -69,7 +69,7 @@
t.integer "item_count"
end

create_table "diaper_drive_participants", force: :cascade do |t|
create_table "diaper_drive_participants", id: :serial, force: :cascade do |t|
t.string "name"
t.string "contact_name"
t.string "email"
Expand All @@ -82,10 +82,10 @@
t.string "business_name"
end

create_table "distributions", force: :cascade do |t|
create_table "distributions", id: :serial, force: :cascade do |t|
t.text "comment"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "storage_location_id"
t.integer "partner_id"
t.integer "organization_id"
Expand All @@ -96,20 +96,20 @@
t.index ["storage_location_id"], name: "index_distributions_on_storage_location_id"
end

create_table "donation_sites", force: :cascade do |t|
create_table "donation_sites", id: :serial, force: :cascade do |t|
t.string "name"
t.string "address"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "organization_id"
t.index ["organization_id"], name: "index_donation_sites_on_organization_id"
end

create_table "donations", force: :cascade do |t|
create_table "donations", id: :serial, force: :cascade do |t|
t.string "source"
t.integer "donation_site_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "storage_location_id"
t.text "comment"
t.integer "organization_id"
Expand All @@ -120,27 +120,27 @@
t.index ["storage_location_id"], name: "index_donations_on_storage_location_id"
end

create_table "inventory_items", force: :cascade do |t|
create_table "inventory_items", id: :serial, force: :cascade do |t|
t.integer "storage_location_id"
t.integer "item_id"
t.integer "quantity", default: 0
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "items", force: :cascade do |t|
create_table "items", id: :serial, force: :cascade do |t|
t.string "name"
t.string "category"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "barcode_count"
t.integer "organization_id"
t.integer "canonical_item_id"
t.boolean "active", default: true
t.index ["organization_id"], name: "index_items_on_organization_id"
end

create_table "line_items", force: :cascade do |t|
create_table "line_items", id: :serial, force: :cascade do |t|
t.integer "quantity"
t.integer "item_id"
t.integer "itemizable_id"
Expand All @@ -150,7 +150,7 @@
t.index ["itemizable_id", "itemizable_type"], name: "index_line_items_on_itemizable_id_and_itemizable_type"
end

create_table "organizations", force: :cascade do |t|
create_table "organizations", id: :serial, force: :cascade do |t|
t.string "name"
t.string "short_name"
t.string "email"
Expand All @@ -165,11 +165,11 @@
t.index ["short_name"], name: "index_organizations_on_short_name"
end

create_table "partners", force: :cascade do |t|
create_table "partners", id: :serial, force: :cascade do |t|
t.string "name"
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "organization_id"
t.index ["organization_id"], name: "index_partners_on_organization_id"
end
Expand All @@ -187,16 +187,16 @@
t.index ["storage_location_id"], name: "index_purchases_on_storage_location_id"
end

create_table "storage_locations", force: :cascade do |t|
create_table "storage_locations", id: :serial, force: :cascade do |t|
t.string "name"
t.string "address"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "organization_id"
t.index ["organization_id"], name: "index_storage_locations_on_organization_id"
end

create_table "transfers", force: :cascade do |t|
create_table "transfers", id: :serial, force: :cascade do |t|
t.integer "from_id"
t.integer "to_id"
t.string "comment"
Expand All @@ -206,7 +206,7 @@
t.index ["organization_id"], name: "index_transfers_on_organization_id"
end

create_table "users", force: :cascade do |t|
create_table "users", id: :serial, force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
Expand Down

0 comments on commit 4276198

Please sign in to comment.