diff --git a/.app_version b/.app_version index 0f1a7dfc..9b1bb851 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.37.0 +0.37.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index fe29bbb3..9e43696c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +# [0.37.1] - 2025-12-30 + +## Fixed + +- The db migration preventing the app from starting. +- Raw data archive verifier now allows having points deleted from the db after archiving. + # [0.37.0] - 2025-12-30 ## Added diff --git a/app/services/points/raw_data/verifier.rb b/app/services/points/raw_data/verifier.rb index de42229f..2da7dfc2 100644 --- a/app/services/points/raw_data/verifier.rb +++ b/app/services/points/raw_data/verifier.rb @@ -110,18 +110,24 @@ module Points return { success: false, error: 'Point IDs checksum mismatch' } end - # 8. Verify all points still exist in database + # 8. Check which points still exist in database (informational only) existing_count = Point.where(id: point_ids).count if existing_count != point_ids.count - return { - success: false, - error: "Missing points in database: expected #{point_ids.count}, found #{existing_count}" - } + Rails.logger.info( + "Archive #{archive.id}: #{point_ids.count - existing_count} points no longer in database " \ + "(#{existing_count}/#{point_ids.count} remaining). This is OK if user deleted their data." + ) end - # 9. Verify archived raw_data matches current database raw_data - verification_result = verify_raw_data_matches(archived_data) - return verification_result unless verification_result[:success] + # 9. Verify archived raw_data matches current database raw_data (only for existing points) + if existing_count.positive? + verification_result = verify_raw_data_matches(archived_data) + return verification_result unless verification_result[:success] + else + Rails.logger.info( + "Archive #{archive.id}: Skipping raw_data verification - no points remain in database" + ) + end { success: true } end @@ -149,11 +155,18 @@ module Points point_ids_to_check = archived_data.keys.sample(100) end - mismatches = [] - found_points = 0 + # Filter to only check points that still exist in the database + existing_point_ids = Point.where(id: point_ids_to_check).pluck(:id) + + if existing_point_ids.empty? + # No points remain to verify, but that's OK + Rails.logger.info("No points remaining to verify raw_data matches") + return { success: true } + end - Point.where(id: point_ids_to_check).find_each do |point| - found_points += 1 + mismatches = [] + + Point.where(id: existing_point_ids).find_each do |point| archived_raw_data = archived_data[point.id] current_raw_data = point.raw_data @@ -167,14 +180,6 @@ module Points end end - # Check if we found all the points we were looking for - if found_points != point_ids_to_check.size - return { - success: false, - error: "Missing points during data verification: expected #{point_ids_to_check.size}, found #{found_points}" - } - end - if mismatches.any? return { success: false, diff --git a/db/migrate/20250513164521_add_visited_countries_to_trips.rb b/db/migrate/20250513164521_add_visited_countries_to_trips.rb index 27797428..d40359d5 100644 --- a/db/migrate/20250513164521_add_visited_countries_to_trips.rb +++ b/db/migrate/20250513164521_add_visited_countries_to_trips.rb @@ -2,10 +2,8 @@ class AddVisitedCountriesToTrips < ActiveRecord::Migration[8.0] def change - # safety_assured do - execute <<-SQL + execute <<-SQL ALTER TABLE trips ADD COLUMN visited_countries JSONB DEFAULT '{}'::jsonb NOT NULL; - SQL - # end + SQL end end diff --git a/db/migrate/20250918215512_add_h3_hex_ids_to_stats.rb b/db/migrate/20250918215512_add_h3_hex_ids_to_stats.rb index fbb19073..18d56394 100644 --- a/db/migrate/20250918215512_add_h3_hex_ids_to_stats.rb +++ b/db/migrate/20250918215512_add_h3_hex_ids_to_stats.rb @@ -5,10 +5,8 @@ class AddH3HexIdsToStats < ActiveRecord::Migration[8.0] def change add_column :stats, :h3_hex_ids, :jsonb, default: {}, if_not_exists: true - # safety_assured do - add_index :stats, :h3_hex_ids, using: :gin, - where: "(h3_hex_ids IS NOT NULL AND h3_hex_ids != '{}'::jsonb)", - algorithm: :concurrently, if_not_exists: true - # end + add_index :stats, :h3_hex_ids, using: :gin, + where: "(h3_hex_ids IS NOT NULL AND h3_hex_ids != '{}'::jsonb)", + algorithm: :concurrently, if_not_exists: true end end diff --git a/db/migrate/20251227223614_change_digests_distance_to_bigint.rb b/db/migrate/20251227223614_change_digests_distance_to_bigint.rb index 9467fa39..a504614e 100644 --- a/db/migrate/20251227223614_change_digests_distance_to_bigint.rb +++ b/db/migrate/20251227223614_change_digests_distance_to_bigint.rb @@ -4,10 +4,10 @@ class ChangeDigestsDistanceToBigint < ActiveRecord::Migration[8.0] disable_ddl_transaction! def up - safety_assured { change_column :digests, :distance, :bigint, null: false, default: 0 } + change_column :digests, :distance, :bigint, null: false, default: 0 end def down - safety_assured { change_column :digests, :distance, :integer, null: false, default: 0 } + change_column :digests, :distance, :integer, null: false, default: 0 end end