Added description, user_id, user_ip columns to notes
Added migration for adding new columns (description, user_id, user_ip) to notes table. Also, migration adds foreign key connecting notes and users tables (using user_id column).
This commit is contained in:
parent
5d76ec051e
commit
16bdcac6d7
3 changed files with 37 additions and 9 deletions
|
@ -10,6 +10,9 @@
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# status :enum not null
|
# status :enum not null
|
||||||
# closed_at :datetime
|
# closed_at :datetime
|
||||||
|
# description :text default(""), not null
|
||||||
|
# user_id :bigint(8)
|
||||||
|
# user_ip :inet
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -17,6 +20,10 @@
|
||||||
# notes_tile_status_idx (tile,status)
|
# notes_tile_status_idx (tile,status)
|
||||||
# notes_updated_at_idx (updated_at)
|
# notes_updated_at_idx (updated_at)
|
||||||
#
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# notes_user_id_fkey (user_id => users.id)
|
||||||
|
#
|
||||||
|
|
||||||
class Note < ApplicationRecord
|
class Note < ApplicationRecord
|
||||||
include GeoRecord
|
include GeoRecord
|
||||||
|
|
9
db/migrate/20250104140952_add_description_to_notes.rb
Normal file
9
db/migrate/20250104140952_add_description_to_notes.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class AddDescriptionToNotes < ActiveRecord::Migration[7.2]
|
||||||
|
def change
|
||||||
|
add_column :notes, :description, :text, :null => false, :default => ""
|
||||||
|
add_column :notes, :user_id, :bigint
|
||||||
|
add_column :notes, :user_ip, :inet
|
||||||
|
|
||||||
|
add_foreign_key :notes, :users, :column => :user_id, :name => "notes_user_id_fkey", :validate => false
|
||||||
|
end
|
||||||
|
end
|
|
@ -1073,7 +1073,10 @@ CREATE TABLE public.notes (
|
||||||
updated_at timestamp without time zone NOT NULL,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
status public.note_status_enum NOT NULL,
|
status public.note_status_enum NOT NULL,
|
||||||
closed_at timestamp without time zone
|
closed_at timestamp without time zone,
|
||||||
|
description text DEFAULT ''::text NOT NULL,
|
||||||
|
user_id bigint,
|
||||||
|
user_ip inet
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -3210,6 +3213,14 @@ ALTER TABLE ONLY public.note_comments
|
||||||
ADD CONSTRAINT note_comments_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
|
ADD CONSTRAINT note_comments_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: notes notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.notes
|
||||||
|
ADD CONSTRAINT notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) NOT VALID;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: redactions redactions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
-- Name: redactions redactions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3397,6 +3408,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('23'),
|
('23'),
|
||||||
('22'),
|
('22'),
|
||||||
('21'),
|
('21'),
|
||||||
|
('20250104140952'),
|
||||||
('20241023004427'),
|
('20241023004427'),
|
||||||
('20241022141247'),
|
('20241022141247'),
|
||||||
('20240913171951'),
|
('20240913171951'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue