Skip to content

Commit

Permalink
Fix DB migration
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Oct 17, 2023
1 parent 10f6859 commit 2273cf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class <%= migration_name %> < ActiveRecord::Migration::Current

create_table :snapshot_items<%= table_options %> do |t|
t.belongs_to :snapshot, null: false, index: true
t.belongs_to :item, polymorphic: true, null: false, unique: [:snapshot_id], index: true
t.belongs_to :item, polymorphic: true, null: false, index: true
t.index [:snapshot_id, :item_id, :item_type], unique: true

t.<%= ActiveSnapshot.config.storage_method == 'native_json' ? 'json' : 'text' %> :object, null: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ def change
t.string :identifier, index: true
t.index [:identifier, :item_id, :item_type], unique: true

t.<%= ActiveSnapshot.config.storage_method == 'native_json' ? 'json' : 'text' %> :metadata, null: false
if ActiveSnapshot.config.storage_method == 'native_json'
t.json :metadata, null: false
else
t.text :metadata, null: false
end

t.datetime :created_at, null: false
end

create_table :snapshot_items do |t|
t.belongs_to :snapshot, null: false, index: true
t.belongs_to :item, polymorphic: true, null: false, unique: [:snapshot_id], index: true
t.belongs_to :item, polymorphic: true, null: false, index: true
t.index [:snapshot_id, :item_id, :item_type], unique: true

t.<%= ActiveSnapshot.config.storage_method == 'native_json' ? 'json' : 'text' %> :object, null: false
if ActiveSnapshot.config.storage_method == 'native_json'
t.json :object, null: false
else
t.text :object, null: false
end

t.datetime :created_at, null: false
t.string :child_group_name
Expand Down

0 comments on commit 2273cf3

Please sign in to comment.