From 161daa4439f2008bb84b4a0c35c229d40ef37456 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 27 Apr 2017 09:22:42 +0300 Subject: [PATCH] Revert b254a7396a199ef49dd6e3e8d83ff61ac820fed7 #475 --- app/models/version/pricelist_version.rb | 4 ++ .../20170423145057_remove_log_pricelists.rb | 5 -- db/schema-read-only.rb | 12 ++++ db/structure.sql | 62 +++++++++++++++++-- spec/models/billing/price_spec.rb | 1 + 5 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 app/models/version/pricelist_version.rb delete mode 100644 db/migrate/20170423145057_remove_log_pricelists.rb diff --git a/app/models/version/pricelist_version.rb b/app/models/version/pricelist_version.rb new file mode 100644 index 000000000..cd86f6064 --- /dev/null +++ b/app/models/version/pricelist_version.rb @@ -0,0 +1,4 @@ +class PricelistVersion < PaperTrail::Version + self.table_name = :log_pricelists + self.sequence_name = :log_pricelists_id_seq +end diff --git a/db/migrate/20170423145057_remove_log_pricelists.rb b/db/migrate/20170423145057_remove_log_pricelists.rb deleted file mode 100644 index c46921764..000000000 --- a/db/migrate/20170423145057_remove_log_pricelists.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveLogPricelists < ActiveRecord::Migration - def change - drop_table :log_pricelists - end -end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 9c6ac0bb2..4c6eb5eef 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -825,6 +825,18 @@ ActiveRecord::Schema.define(version: 20170424115801) do add_index "log_nameservers", ["item_type", "item_id"], name: "index_log_nameservers_on_item_type_and_item_id", using: :btree add_index "log_nameservers", ["whodunnit"], name: "index_log_nameservers_on_whodunnit", using: :btree + create_table "log_pricelists", force: :cascade do |t| + t.string "item_type", null: false + t.integer "item_id", null: false + t.string "event", null: false + t.string "whodunnit" + t.json "object" + t.json "object_changes" + t.datetime "created_at" + t.string "session" + t.string "uuid" + end + create_table "log_registrars", force: :cascade do |t| t.string "item_type", null: false t.integer "item_id", null: false diff --git a/db/structure.sql b/db/structure.sql index 322f11f9e..f349138e2 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2147,6 +2147,43 @@ CREATE SEQUENCE log_nameservers_id_seq ALTER SEQUENCE log_nameservers_id_seq OWNED BY log_nameservers.id; +-- +-- Name: log_pricelists; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE log_pricelists ( + id integer NOT NULL, + item_type character varying NOT NULL, + item_id integer NOT NULL, + event character varying NOT NULL, + whodunnit character varying, + object json, + object_changes json, + created_at timestamp without time zone, + session character varying, + uuid character varying +); + + +-- +-- Name: log_pricelists_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE log_pricelists_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: log_pricelists_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE log_pricelists_id_seq OWNED BY log_pricelists.id; + + -- -- Name: log_registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2490,7 +2527,7 @@ ALTER SEQUENCE people_id_seq OWNED BY people.id; -- --- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE prices ( @@ -3263,6 +3300,13 @@ ALTER TABLE ONLY log_messages ALTER COLUMN id SET DEFAULT nextval('log_messages_ ALTER TABLE ONLY log_nameservers ALTER COLUMN id SET DEFAULT nextval('log_nameservers_id_seq'::regclass); +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY log_pricelists ALTER COLUMN id SET DEFAULT nextval('log_pricelists_id_seq'::regclass); + + -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3779,6 +3823,14 @@ ALTER TABLE ONLY log_nameservers ADD CONSTRAINT log_nameservers_pkey PRIMARY KEY (id); +-- +-- Name: log_pricelists_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY log_pricelists + ADD CONSTRAINT log_pricelists_pkey PRIMARY KEY (id); + + -- -- Name: log_registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3852,7 +3904,7 @@ ALTER TABLE ONLY people -- --- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY prices @@ -3900,7 +3952,7 @@ ALTER TABLE ONLY settings -- --- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY zones @@ -4606,7 +4658,7 @@ CREATE UNIQUE INDEX index_people_on_reset_password_token ON people USING btree ( -- --- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_prices_on_zone_id ON prices USING btree (zone_id); @@ -5193,8 +5245,6 @@ INSERT INTO schema_migrations (version) VALUES ('20170422142116'); INSERT INTO schema_migrations (version) VALUES ('20170422162824'); -INSERT INTO schema_migrations (version) VALUES ('20170423145057'); - INSERT INTO schema_migrations (version) VALUES ('20170423151046'); INSERT INTO schema_migrations (version) VALUES ('20170423210622'); diff --git a/spec/models/billing/price_spec.rb b/spec/models/billing/price_spec.rb index b0e83898a..84b100bc5 100644 --- a/spec/models/billing/price_spec.rb +++ b/spec/models/billing/price_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' RSpec.describe Billing::Price do it { is_expected.to monetize(:price) } + it { is_expected.to be_versioned } describe '::operation_categories', db: false do it 'returns available operation categories' do