diff --git a/app/models/store_item.rb b/app/models/store_item.rb index 75ea2ec4..df60a6f3 100644 --- a/app/models/store_item.rb +++ b/app/models/store_item.rb @@ -9,7 +9,7 @@ # **`created_at`** | `datetime` | `not null` # **`id`** | `integer` | `not null, primary key` # **`name`** | `string(255)` | -# **`price`** | `decimal(10, )` | +# **`price`** | `decimal(8, 2)` | # **`quantity`** | `integer` | # **`updated_at`** | `datetime` | `not null` # diff --git a/app/models/store_purchase.rb b/app/models/store_purchase.rb index 64683360..332ef98b 100644 --- a/app/models/store_purchase.rb +++ b/app/models/store_purchase.rb @@ -9,7 +9,7 @@ # **`charge_id`** | `integer` | # **`created_at`** | `datetime` | `not null` # **`id`** | `integer` | `not null, primary key` -# **`price_at_purchase`** | `decimal(10, )` | +# **`price_at_purchase`** | `decimal(8, 2)` | # **`quantity_purchased`** | `integer` | # **`store_item_id`** | `integer` | # **`updated_at`** | `datetime` | `not null` diff --git a/db/migrate/20170323163001_change_store_item_price_datatype.rb b/db/migrate/20170323163001_change_store_item_price_datatype.rb new file mode 100644 index 00000000..9b767922 --- /dev/null +++ b/db/migrate/20170323163001_change_store_item_price_datatype.rb @@ -0,0 +1,6 @@ +class ChangeStoreItemPriceDatatype < ActiveRecord::Migration + def change + change_column :store_items, :price, :decimal, :precision => 8, :scale => 2 + change_column :store_purchases, :price_at_purchase, :decimal, :precision => 8, :scale => 2 + end +end diff --git a/db/schema.rb b/db/schema.rb index 7746d390..0d504102 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -250,20 +250,20 @@ add_index "shifts", ["organization_id"], name: "index_shifts_on_organization_id" create_table "store_items", force: :cascade do |t| - t.string "name" - t.decimal "price" - t.integer "quantity" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "name", limit: 255 + t.decimal "price", precision: 8, scale: 2 + t.integer "quantity", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "store_purchases", force: :cascade do |t| - t.integer "charge_id" - t.integer "store_item_id" - t.decimal "price_at_purchase" - t.integer "quantity_purchased" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "charge_id", limit: 4 + t.integer "store_item_id", limit: 4 + t.decimal "price_at_purchase", precision: 8, scale: 2 + t.integer "quantity_purchased", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "store_purchases", ["charge_id"], name: "index_store_purchases_on_charge_id" diff --git a/db/seeds.rb b/db/seeds.rb index f9e6d14b..e08af734 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -719,7 +719,7 @@ # Store ------------------------------------------------------------------------- puts 'Store' -StoreItem.create({ name: '9 Volt Battery', price: 1, quantity: 1000}) +StoreItem.create({ name: '9 Volt Battery', price: 0.99, quantity: 1000}) StoreItem.create({ name: 'Drill Bit', price: 1, quantity: 1000}) StoreItem.create({ name: 'Drop Cloth', price: 2, quantity: 1000}) StoreItem.create({ name: 'Electrical Box - 1 Gang', price: 1, quantity: 1000})