From: https://github.com/openstreetmap/operations/issues/1358

This PR moves the three GPS tables (gpx_files, gpx_file_tags, gps_points) out 
of the main openstreetmap database into a new openstreetmap_gps database.

What the PR does:

- Adds a GpsRecord abstract model connected to the gps database. Trace, 
Tracepoint, and Tracetag inherit from it.
- Adds db/gps_migrate/ and db/gps_structure.sql for the GPS schema.
- Keeps the foreign keys between the three GPS tables. But the link to users.id 
is now app-level only, since Postgres can't enforce FKs across databases.
- Updates CI, Docker, and the devcontainer to set up the second database.
- Feeds controller: removed a join that crossed both databases (Postgres can't 
do that). Now it loads the trace and the user in two steps.
- Trace image/icon attachments: skip blob analysis. Active Storage tries to 
analyze the file by loading the parent record, but the parent (Trace) is now in 
the gps DB while the attachment is in the main DB, so the analyzer crashes. 
seems skipping is safe, because  we don't use the analyzed metadata for those 
files.
- I tested this with the docker-compose dev setup and the trace tests still 
pass.

Some files were auto-updated by Rails when the tables moved: model annotations, 
db/structure.sql, and db/gps_structure.sql. These changes were automatic.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/7111

-- Commit Summary --

  * Add a new gps database for Rails
  * Drop gps tables from main database
  * Add gpx_visibility_enum ENUM for gps_db
  * Drop gpx_visibility_enum using safety_assured
  * Use preload instead of includes to avoid JOIN across databases
  * Handle gps db connection errors to avoid breaking the main site
  * Handle DatabaseConnectionError when gps-db is down adn the site is starting
  * Use traces_count column instead of traces.size to avoid querying gps-db on 
user profile page
  * Merge remote-tracking branch 'upstream/master' into gps_db
  * Configure CI to set up the GPS database
  * Update structure files and model anotations after gps tables move to a 
separate db
  * Add GPS database setup to lint workflow
  * Use hash rockets syntax in GPS files
  * Exclude GPS migration from Rails/ThreeStateBooleanColumn
  * Add foreign keys for intra-gps trace associations
  * Add gps foreign keys with validate: false for strong_migrations
  * Annotate trace models with new foreign keys
  * Fix cross-database join in traces feeds controller
  * Skip blob analysis for trace image and icon attachments
  * Add gps database to docker, devcontainer, and example config

-- File Changes --

    M .github/workflows/lint.yml (2)
    M .github/workflows/tests.yml (6)
    M .rubocop_todo.yml (1)
    M app/controllers/application_controller.rb (15)
    M app/controllers/concerns/pagination_methods.rb (2)
    M app/controllers/traces/feeds_controller.rb (5)
    M app/models/acl.rb (1)
    M app/models/changeset.rb (1)
    M app/models/changeset_comment.rb (1)
    M app/models/changeset_subscription.rb (1)
    M app/models/changeset_tag.rb (1)
    M app/models/diary_comment.rb (1)
    M app/models/diary_entry.rb (1)
    M app/models/diary_entry_subscription.rb (1)
    M app/models/follow.rb (1)
    A app/models/gps_record.rb (6)
    M app/models/issue.rb (1)
    M app/models/issue_comment.rb (1)
    M app/models/language.rb (1)
    M app/models/message.rb (1)
    M app/models/moderation_zone.rb (1)
    M app/models/node.rb (1)
    M app/models/node_tag.rb (1)
    M app/models/note.rb (1)
    M app/models/note_comment.rb (1)
    M app/models/note_subscription.rb (1)
    M app/models/oauth2_application.rb (1)
    M app/models/old_node.rb (1)
    M app/models/old_node_tag.rb (1)
    M app/models/old_relation.rb (1)
    M app/models/old_relation_member.rb (1)
    M app/models/old_relation_tag.rb (1)
    M app/models/old_way.rb (1)
    M app/models/old_way_node.rb (1)
    M app/models/old_way_tag.rb (1)
    M app/models/redaction.rb (1)
    M app/models/relation.rb (1)
    M app/models/relation_member.rb (1)
    M app/models/relation_tag.rb (1)
    M app/models/report.rb (1)
    M app/models/social_link.rb (1)
    M app/models/spammy_phrase.rb (1)
    M app/models/trace.rb (15)
    M app/models/tracepoint.rb (3)
    M app/models/tracetag.rb (5)
    M app/models/user.rb (1)
    M app/models/user_block.rb (1)
    M app/models/user_mute.rb (1)
    M app/models/user_preference.rb (1)
    M app/models/user_role.rb (1)
    M app/models/way.rb (1)
    M app/models/way_node.rb (1)
    M app/models/way_tag.rb (1)
    M app/views/users/show.html.erb (2)
    M config/devcontainer.database.yml (49)
    M config/docker.database.yml (42)
    M config/example.database.yml (63)
    M config/github.database.yml (12)
    A db/gps_migrate/20260325000001_create_gps_tables.rb (47)
    A db/gps_structure.sql (251)
    A db/migrate/20260413000001_drop_gps_tables_from_main_db.rb (15)
    M db/structure.sql (206)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/7111.patch
https://github.com/openstreetmap/openstreetmap-website/pull/7111.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7111
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to