Disputes: Show when and who closed dispute

This commit is contained in:
Karl Erik Õunapuu 2020-05-18 15:11:34 +03:00
parent 26a5813fe9
commit c682155bf6
9 changed files with 48 additions and 31 deletions

View file

@ -0,0 +1,19 @@
class AddClosedDateTimeAndUpdatorToDispute < ActiveRecord::Migration[5.2]
def up
rename_column :disputes, :closed, :closed_boolean
add_column :disputes, :closed, :datetime
execute 'UPDATE disputes SET closed = updated_at WHERE closed_boolean = true'
execute 'UPDATE disputes SET closed = NULL WHERE closed_boolean = false'
remove_column :disputes, :closed_boolean
add_column :disputes, :initiator, :string
end
def down
rename_column :disputes, :closed, :closed_datetime
add_column :disputes, :closed, :boolean, null: false, default: false
execute 'UPDATE disputes SET closed = true WHERE closed_datetime != NULL'
execute 'UPDATE disputes SET closed = false WHERE closed_datetime = NULL'
remove_column :disputes, :closed_datetime
remove_column :disputes, :initiator
end
end

View file

@ -1,6 +1,6 @@
--
-- PostgreSQL database dump
--
---
--- PostgreSQL database dump
---
SET statement_timeout = 0;
SET lock_timeout = 0;
@ -605,9 +605,10 @@ CREATE TABLE public.disputes (
expires_at date NOT NULL,
starts_at date NOT NULL,
comment text,
closed boolean DEFAULT false 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,
closed timestamp without time zone,
initiator character varying
);
@ -4520,5 +4521,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200417075720'),
('20200421093637'),
('20200505103316'),
('20200505150413');
('20200505150413'),
('20200518104105');