Skip to content

Commit

Permalink
Add ActionVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Jun 26, 2019
1 parent f5ab781 commit 7fdaf1d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/action.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Action < ActiveRecord::Base
has_paper_trail

belongs_to :user
belongs_to :contact

Expand Down
4 changes: 4 additions & 0 deletions app/models/version/action_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ActionVersion < PaperTrail::Version
self.table_name = :log_actions
self.sequence_name = :log_actions_id_seq
end
16 changes: 16 additions & 0 deletions db/migrate/20190620084334_create_log_actions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreateLogActions < ActiveRecord::Migration
def change
create_table :log_actions do |t|
t.string :item_type, null: false
t.integer :item_id, null: false
t.string :event, null: false
t.string :whodunnit
t.jsonb :object
t.jsonb :object_changes
t.datetime :created_at
t.string :session
t.jsonb :children
t.string :uuid
end
end
end
55 changes: 55 additions & 0 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,44 @@ CREATE SEQUENCE public.log_accounts_id_seq
ALTER SEQUENCE public.log_accounts_id_seq OWNED BY public.log_accounts.id;


--
-- Name: log_actions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--

CREATE TABLE public.log_actions (
id integer NOT NULL,
item_type character varying NOT NULL,
item_id integer NOT NULL,
event character varying NOT NULL,
whodunnit character varying,
object jsonb,
object_changes jsonb,
created_at timestamp without time zone,
session character varying,
children jsonb,
uuid character varying
);


--
-- Name: log_actions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.log_actions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: log_actions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.log_actions_id_seq OWNED BY public.log_actions.id;


--
-- Name: log_bank_statements; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
Expand Down Expand Up @@ -2506,6 +2544,13 @@ ALTER TABLE ONLY public.log_account_activities ALTER COLUMN id SET DEFAULT nextv
ALTER TABLE ONLY public.log_accounts ALTER COLUMN id SET DEFAULT nextval('public.log_accounts_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.log_actions ALTER COLUMN id SET DEFAULT nextval('public.log_actions_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2891,6 +2936,14 @@ ALTER TABLE ONLY public.log_accounts
ADD CONSTRAINT log_accounts_pkey PRIMARY KEY (id);


--
-- Name: log_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--

ALTER TABLE ONLY public.log_actions
ADD CONSTRAINT log_actions_pkey PRIMARY KEY (id);


--
-- Name: log_bank_statements_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
Expand Down Expand Up @@ -4763,3 +4816,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190617121949');

INSERT INTO schema_migrations (version) VALUES ('20190617122505');

INSERT INTO schema_migrations (version) VALUES ('20190620084334');

0 comments on commit 7fdaf1d

Please sign in to comment.