Make migrations reversible
This commit is contained in:
committed by
Mike Dalessio
parent
ea970b195a
commit
067e889cb4
@@ -1,7 +1,7 @@
|
||||
class CreateSearchRecordShards < ActiveRecord::Migration[8.2]
|
||||
SHARD_COUNT = 16
|
||||
|
||||
def up
|
||||
def change
|
||||
# Create 16 sharded search_records tables
|
||||
SHARD_COUNT.times do |shard_id|
|
||||
create_table "search_records_#{shard_id}", id: :uuid do |t|
|
||||
@@ -22,13 +22,18 @@ class CreateSearchRecordShards < ActiveRecord::Migration[8.2]
|
||||
|
||||
# Drop old search_index tables
|
||||
SHARD_COUNT.times do |shard_id|
|
||||
drop_table "search_index_#{shard_id}", if_exists: true
|
||||
end
|
||||
end
|
||||
drop_table "search_index_#{shard_id}", if_exists: true do |t|
|
||||
t.string :searchable_type, null: false
|
||||
t.uuid :searchable_id, null: false
|
||||
t.uuid :card_id, null: false
|
||||
t.uuid :board_id, null: false
|
||||
t.string :title
|
||||
t.text :content
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
def down
|
||||
SHARD_COUNT.times do |shard_id|
|
||||
drop_table "search_records_#{shard_id}"
|
||||
t.index [:searchable_type, :searchable_id], unique: true, name: "idx_si#{shard_id}_type_id"
|
||||
t.index [:content, :title], type: :fulltext, name: "idx_si#{shard_id}_fulltext"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class DropSearchResults < ActiveRecord::Migration[8.2]
|
||||
def change
|
||||
drop_table :search_results
|
||||
drop_table :search_results do |t|
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user