diff --git a/app/models/event/synchronized_editor.rb b/app/models/event/synchronized_editor.rb index 57796f7a..cbb8dc99 100644 --- a/app/models/event/synchronized_editor.rb +++ b/app/models/event/synchronized_editor.rb @@ -31,6 +31,7 @@ class Event::SynchronizedEditor < ApplicationRecord validates :status, presence: true, if: -> { action_connection_change? } validates :file_id, presence: true, if: -> { action_editor_change? } + validates :session_id, presence: true, if: -> { action_editor_change? } validates :editor_action, presence: true, if: -> { action_editor_change? } validates :range_start_row, numericality: {only_integer: true, greater_than_or_equal_to: 0}, if: -> { action_editor_change? } validates :range_start_column, numericality: {only_integer: true, greater_than_or_equal_to: 0}, if: -> { action_editor_change? } @@ -53,6 +54,7 @@ class Event::SynchronizedEditor < ApplicationRecord action: event_copy.delete(:action), editor_action: delta.delete(:action), file_id: file[:id], + session_id: event_copy.delete(:session_id), range_start_row: range[:start][:row], range_start_column: range[:start][:column], range_end_row: range[:end][:row], diff --git a/db/migrate/20230908091810_add_session_id_to_events_synrhonized_editor.rb b/db/migrate/20230908091810_add_session_id_to_events_synrhonized_editor.rb new file mode 100644 index 00000000..9655fe08 --- /dev/null +++ b/db/migrate/20230908091810_add_session_id_to_events_synrhonized_editor.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSessionIdToEventsSynrhonizedEditor < ActiveRecord::Migration[7.0] + def change + add_column :events_synchronized_editor, :session_id, :uuid, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 8225c522..1ff0a1dc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_06_163923) do +ActiveRecord::Schema[7.0].define(version: 2023_09_08_091810) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" enable_extension "pgcrypto" @@ -168,6 +168,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_06_163923) do t.jsonb "data" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.uuid "session_id" t.index ["file_id"], name: "index_events_synchronized_editor_on_file_id" t.index ["programming_group_id"], name: "index_events_synchronized_editor_on_programming_group_id" t.index ["study_group_id"], name: "index_events_synchronized_editor_on_study_group_id"