2025-09-18 18:23:12 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class AddH3HexIdsToStats < ActiveRecord::Migration[8.0]
|
2025-09-19 13:55:27 -04:00
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
2025-09-18 18:23:12 -04:00
|
|
|
def change
|
2025-09-20 09:55:10 -04:00
|
|
|
add_column :stats, :h3_hex_ids, :jsonb, default: {}, if_not_exists: true
|
2025-09-20 09:53:27 -04:00
|
|
|
safety_assured do
|
|
|
|
|
add_index :stats, :h3_hex_ids, using: :gin,
|
|
|
|
|
where: "(h3_hex_ids IS NOT NULL AND h3_hex_ids != '{}'::jsonb)",
|
2025-09-20 09:55:10 -04:00
|
|
|
algorithm: :concurrently, if_not_exists: true
|
2025-09-20 09:53:27 -04:00
|
|
|
end
|
2025-09-18 18:23:12 -04:00
|
|
|
end
|
|
|
|
|
end
|