# Live collaboration (Yjs): a document's content is the sum of its Yjs # updates. `documents.content` stays as a JSON snapshot (duplicate, export, # the first conversion to Yjs). The edit lock and version counter go. class LiveCollaboration < ActiveRecord::Migration[8.1] def change create_table :document_updates do |t| t.references :document, type: :uuid, null: false, foreign_key: { on_delete: :cascade } t.references :user, foreign_key: { on_delete: :nullify } t.binary :data, null: false t.datetime :created_at, null: false end remove_column :documents, :version, :integer, null: false, default: 1 remove_column :documents, :lock_holder, :string remove_column :documents, :lock_holder_name, :string remove_column :documents, :lock_expires_at, :datetime end end