mirror of
https://github.com/usetrmnl/terminus.git
synced 2026-08-13 14:29:27 -07:00
Added screen migration set device ID to null when device is deleted
Relaxes deleting of the screen when the associated device is deleted. Instead we set the `device_id` foreign key to `null` like we do for the `template_id` foreign key. This allows a screen to remain in case you want to repurpose it for another device. Milestone: patch
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ROM::SQL.migration do
|
||||
up do
|
||||
alter_table :screen do
|
||||
drop_foreign_key [:device_id]
|
||||
add_foreign_key [:device_id], :device, on_update: :cascade, on_delete: :set_null
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table :screen do
|
||||
drop_foreign_key [:device_id]
|
||||
add_foreign_key [:device_id], :device, on_update: :cascade, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1654,7 +1654,7 @@ ALTER TABLE ONLY public.playlist_item
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.screen
|
||||
ADD CONSTRAINT screen_device_id_fkey FOREIGN KEY (device_id) REFERENCES public.device(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
ADD CONSTRAINT screen_device_id_fkey FOREIGN KEY (device_id) REFERENCES public.device(id) ON UPDATE CASCADE ON DELETE SET NULL;
|
||||
|
||||
|
||||
--
|
||||
@@ -1805,4 +1805,5 @@ INSERT INTO schema_migrations (filename) VALUES
|
||||
('20260630091508_add_device_log_level_column.rb'),
|
||||
('20260714090149_add_device_api_key_column.rb'),
|
||||
('20260721160734_add_device_command_column.rb'),
|
||||
('20260721160742_rename_device_log_function_columan_as_command.rb');
|
||||
('20260721160742_rename_device_log_function_columan_as_command.rb'),
|
||||
('20260805142625_alter_screen_device_id_constraint.rb');
|
||||
|
||||
Reference in New Issue
Block a user