mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Merge pull request #980 from internetee/remove-paper-trail-columns-from-prices
Return version logging to `prices` DB table
This commit is contained in:
commit
e14b0c9186
4 changed files with 93 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
module Billing
|
module Billing
|
||||||
class Price < ApplicationRecord
|
class Price < ApplicationRecord
|
||||||
include Concerns::Billing::Price::Expirable
|
include Concerns::Billing::Price::Expirable
|
||||||
|
include Versions
|
||||||
|
|
||||||
belongs_to :zone, class_name: 'DNS::Zone', required: true
|
belongs_to :zone, class_name: 'DNS::Zone', required: true
|
||||||
has_many :account_activities
|
has_many :account_activities
|
||||||
|
|
7
app/models/version/billing/price_version.rb
Normal file
7
app/models/version/billing/price_version.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module Billing
|
||||||
|
class PriceVersion < PaperTrail::Version
|
||||||
|
self.table_name = :log_prices
|
||||||
|
self.sequence_name = :log_prices_id_seq
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
26
db/migrate/20200910102028_create_version_for_prices.rb
Normal file
26
db/migrate/20200910102028_create_version_for_prices.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
class CreateVersionForPrices < ActiveRecord::Migration[6.0]
|
||||||
|
def up
|
||||||
|
create_table :log_prices, 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.json :children
|
||||||
|
t.string :uuid
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index 'log_prices', ['item_type', 'item_id'], name: 'index_log_prices_on_item_type_and_item_id', using: :btree
|
||||||
|
add_index 'log_prices', ['whodunnit'], name: 'index_log_prices_on_whodunnit', using: :btree
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :log_prices, name: 'index_log_prices_on_item_type_and_item_id'
|
||||||
|
remove_index :log_prices, name: 'index_log_prices_on_whodunnit'
|
||||||
|
|
||||||
|
drop_table :log_prices
|
||||||
|
end
|
||||||
|
end
|
|
@ -1706,7 +1706,45 @@ ALTER SEQUENCE public.log_payment_orders_id_seq OWNED BY public.log_payment_orde
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: log_registrant_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
-- Name: log_prices; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.log_prices (
|
||||||
|
id bigint 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,
|
||||||
|
children json,
|
||||||
|
uuid character varying
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_prices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.log_prices_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_prices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.log_prices_id_seq OWNED BY public.log_prices.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_registrant_verifications; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE public.log_registrant_verifications (
|
CREATE TABLE public.log_registrant_verifications (
|
||||||
|
@ -2092,8 +2130,8 @@ CREATE TABLE public.prices (
|
||||||
price_cents integer NOT NULL,
|
price_cents integer 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,
|
|
||||||
updator_str character varying,
|
updator_str character varying,
|
||||||
|
creator_str character varying,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
duration interval,
|
duration interval,
|
||||||
|
@ -2838,7 +2876,14 @@ ALTER TABLE ONLY public.log_payment_orders ALTER COLUMN id SET DEFAULT nextval('
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: log_prices id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.log_prices ALTER COLUMN id SET DEFAULT nextval('public.log_prices_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_registrant_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY public.log_registrant_verifications ALTER COLUMN id SET DEFAULT nextval('public.log_registrant_verifications_id_seq'::regclass);
|
ALTER TABLE ONLY public.log_registrant_verifications ALTER COLUMN id SET DEFAULT nextval('public.log_registrant_verifications_id_seq'::regclass);
|
||||||
|
@ -3304,7 +3349,15 @@ ALTER TABLE ONLY public.log_payment_orders
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: log_registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
-- Name: log_prices log_prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.log_prices
|
||||||
|
ADD CONSTRAINT log_prices_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_registrant_verifications log_registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY public.log_registrant_verifications
|
ALTER TABLE ONLY public.log_registrant_verifications
|
||||||
|
@ -4851,6 +4904,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20200812090409'),
|
('20200812090409'),
|
||||||
('20200812125810'),
|
('20200812125810'),
|
||||||
('20200908131554'),
|
('20200908131554'),
|
||||||
('20200910085157');
|
('20200910085157'),
|
||||||
|
('20200910102028');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue