Refactor price db structure

#475
This commit is contained in:
Artur Beljajev 2017-04-24 01:33:04 +03:00
parent c5d667c711
commit 48135ba72c
6 changed files with 27 additions and 9 deletions

View file

@ -0,0 +1,5 @@
class ChangePricePriceCentsTypeToInteger < ActiveRecord::Migration
def change
change_column :prices, :price_cents, 'integer USING CAST(price_cents AS integer)'
end
end

View file

@ -0,0 +1,5 @@
class RemovePricePriceCurrency < ActiveRecord::Migration
def change
remove_column :prices, :price_currency, :string
end
end

View file

@ -0,0 +1,5 @@
class RemovePricePriceCentsDefault < ActiveRecord::Migration
def change
change_column_default :prices, :price_cents, nil
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170423151046) do ActiveRecord::Schema.define(version: 20170423222302) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -964,14 +964,13 @@ ActiveRecord::Schema.define(version: 20170423151046) do
create_table "prices", force: :cascade do |t| create_table "prices", force: :cascade do |t|
t.string "desc" t.string "desc"
t.string "category" t.string "category"
t.decimal "price_cents", precision: 10, scale: 2, default: 0.0, null: false t.integer "price_cents", null: false
t.string "price_currency", default: "EUR", null: false
t.datetime "valid_from" t.datetime "valid_from"
t.datetime "valid_to" t.datetime "valid_to"
t.string "creator_str" t.string "creator_str"
t.string "updator_str" t.string "updator_str"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "duration" t.string "duration"
t.string "operation_category" t.string "operation_category"
end end

View file

@ -2497,8 +2497,7 @@ CREATE TABLE prices (
id integer NOT NULL, id integer NOT NULL,
"desc" character varying, "desc" character varying,
category character varying, category character varying,
price_cents numeric(10,2) DEFAULT 0.0 NOT NULL, price_cents integer NOT NULL,
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
valid_from timestamp without time zone, valid_from timestamp without time zone,
valid_to timestamp without time zone, valid_to timestamp without time zone,
creator_str character varying, creator_str character varying,
@ -5175,3 +5174,9 @@ INSERT INTO schema_migrations (version) VALUES ('20170423145057');
INSERT INTO schema_migrations (version) VALUES ('20170423151046'); INSERT INTO schema_migrations (version) VALUES ('20170423151046');
INSERT INTO schema_migrations (version) VALUES ('20170423210622');
INSERT INTO schema_migrations (version) VALUES ('20170423214500');
INSERT INTO schema_migrations (version) VALUES ('20170423222302');

View file

@ -2006,8 +2006,7 @@
<text text-anchor="start" x="3606.5" y="-668.8" font-family="Times,serif" font-size="14.00">id :integer</text> <text text-anchor="start" x="3606.5" y="-668.8" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="3606.5" y="-653.8" font-family="Times,serif" font-size="14.00">desc :string</text> <text text-anchor="start" x="3606.5" y="-653.8" font-family="Times,serif" font-size="14.00">desc :string</text>
<text text-anchor="start" x="3606.5" y="-638.8" font-family="Times,serif" font-size="14.00">category :string</text> <text text-anchor="start" x="3606.5" y="-638.8" font-family="Times,serif" font-size="14.00">category :string</text>
<text text-anchor="start" x="3606.5" y="-623.8" font-family="Times,serif" font-size="14.00">price_cents :decimal</text> <text text-anchor="start" x="3606.5" y="-623.8" font-family="Times,serif" font-size="14.00">price_cents :integer</text>
<text text-anchor="start" x="3606.5" y="-608.8" font-family="Times,serif" font-size="14.00">price_currency :string</text>
<text text-anchor="start" x="3606.5" y="-593.8" font-family="Times,serif" font-size="14.00">valid_from :datetime</text> <text text-anchor="start" x="3606.5" y="-593.8" font-family="Times,serif" font-size="14.00">valid_from :datetime</text>
<text text-anchor="start" x="3606.5" y="-578.8" font-family="Times,serif" font-size="14.00">valid_to :datetime</text> <text text-anchor="start" x="3606.5" y="-578.8" font-family="Times,serif" font-size="14.00">valid_to :datetime</text>
<text text-anchor="start" x="3606.5" y="-563.8" font-family="Times,serif" font-size="14.00">creator_str :string</text> <text text-anchor="start" x="3606.5" y="-563.8" font-family="Times,serif" font-size="14.00">creator_str :string</text>

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

Before After
Before After