diff --git a/db/migrate/20241212235258_add_extra_fields_to_gift_cards.rb b/db/migrate/20241212235258_add_extra_fields_to_gift_cards.rb deleted file mode 100644 index 3378fe6..0000000 --- a/db/migrate/20241212235258_add_extra_fields_to_gift_cards.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddExtraFieldsToGiftCards < ActiveRecord::Migration[7.2] - def change - add_column :gift_cards, :prod, :string - add_column :gift_cards, :isbn, :string - add_column :gift_cards, :gl_acct, :string - add_column :gift_cards, :department_number, :string - end -end diff --git a/db/schema.rb b/db/schema.rb index bf08dc1..c76fe44 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,9 +10,12 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_12_235258) do +ActiveRecord::Schema[7.2].define(version: 2024_11_26_111253) do # These are extensions that must be enabled in order to support this database + enable_extension "pg_stat_statements" + enable_extension "pgcrypto" enable_extension "plpgsql" + enable_extension "uuid-ossp" create_table "active_admin_comments", force: :cascade do |t| t.string "namespace" @@ -68,10 +71,6 @@ t.string "gl_code" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "prod" - t.string "isbn" - t.string "gl_acct" - t.string "department_number" end create_table "issuances", force: :cascade do |t| diff --git a/import.rb b/import.rb index 2e5084b..736a23e 100644 --- a/import.rb +++ b/import.rb @@ -99,6 +99,10 @@ issuance.card_amount = 0 issuance.quantity = 0 issuance.save! + + issuance.update_column(:status, "issued") + issuance = Issuance.find(issuance.id) + [ gct, issuance ] end.to_h @@ -121,11 +125,11 @@ gc.gift_card_type = gct gc.expiration_date = DateTime.parse(row["expirationDate"]) gc.registrations_available = row["numberRegistrations"].to_i - gc.certificate_value = row["certificateValue"].to_d - gc.gl_code = row["glCode"].to_d - gc.created_at = row["addDate"].to_d - gc.updated_at = row["modifiedDate"].to_d - gc.associated_product = row["associatedProduct"].to_d + gc.certificate_value = row["certificateValue"] + gc.gl_code = row["glCode"] + gc.created_at = DateTime.parse(row["addDate"]) if row["created_at"] + gc.updated_at = DateTime.parse(row["modifiedDate"]) if row["modifiedDate"] + gc.associated_product = row["associatedProduct"] batch << gc @@ -140,5 +144,3 @@ Issuance.where(quantity: [nil, 0]).each do |i| i.update(quantity: i.gift_cards.count) end - -Issuance.update_column(:status, "issued")