Skip to content

Commit

Permalink
Adds validating of notes foreign key
Browse files Browse the repository at this point in the history
Adds migration for validation foreign key in notes table referencing users table.
  • Loading branch information
nenad-vujicic committed Jan 17, 2025
1 parent 3eccf65 commit 297e837
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions db/migrate/20250105154621_validate_foreign_key_on_notes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ValidateForeignKeyOnNotes < ActiveRecord::Migration[7.2]
def change
validate_foreign_key :notes, :users
end
end
3 changes: 2 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3218,7 +3218,7 @@ ALTER TABLE ONLY public.note_comments
--

ALTER TABLE ONLY public.notes
ADD CONSTRAINT notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) NOT VALID;
ADD CONSTRAINT notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
Expand Down Expand Up @@ -3408,6 +3408,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('23'),
('22'),
('21'),
('20250105154621'),
('20250104140952'),
('20241023004427'),
('20241022141247'),
Expand Down

0 comments on commit 297e837

Please sign in to comment.