Added device table migration for non-null model ID

Necessary to ensure database integrity becauses devices require being associated with a model and it no longer makes sense to do without.

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-01-26 15:06:35 -07:00
parent dcc92c6bff
commit 360ef0ee7b
2 changed files with 9 additions and 2 deletions
@@ -0,0 +1,6 @@
# frozen_string_literal: true
ROM::SQL.migration do
up { alter_table(:device) { set_column_not_null :model_id } }
down { alter_table(:device) { set_column_allow_null :model_id } }
end
+3 -2
View File
@@ -236,7 +236,7 @@ CREATE TABLE public.device (
firmware_update boolean DEFAULT true CONSTRAINT devices_firmware_update_not_null NOT NULL,
sleep_start_at time without time zone,
sleep_stop_at time without time zone,
model_id integer,
model_id integer NOT NULL,
playlist_id integer
);
@@ -1316,4 +1316,5 @@ INSERT INTO schema_migrations (filename) VALUES
('20251201105349_alter_model_firmware_columns.rb'),
('20251211152911_drop_model_published_at_column.rb'),
('20251215154654_add_playlist_mode_enum.rb'),
('20260106144016_alter_firmware_kind.rb');
('20260106144016_alter_firmware_kind.rb'),
('20260126141642_alter_device_table_model_id_as_non_null.rb');