Skip to content

Conversation

Copy link

Copilot AI commented Jan 23, 2026

Implementation Complete: Add ip_address_id to deliveries table

  • Explore repository structure and understand the codebase
  • Create migration to add ip_address_id column to deliveries table in message_db
  • Update Delivery.create method to accept and store ip_address_id (handled automatically)
  • Update message processing to pass ip_address_id when creating deliveries (all statuses)
  • Update the message detail view to display IP address information
  • Add tests for the new functionality
  • Address all code review feedback
  • Security scan completed - no vulnerabilities found
  • Add db:prepare step to CI pipeline
  • Update initial deliveries table schema to include ip_address_id and time fields
  • Make migrations 11 and 21 idempotent to handle both fresh installs and upgrades
  • Fix all CI failures (class naming with acronym inflections, test setup, and associations)

Latest CI Fix

Fixed migration class name to respect Rails acronym inflections. The application has inflect.acronym "IP" configured in config/initializers/inflections.rb, which means camelize treats "IP" as an acronym and keeps it uppercase. Changed class name from AddIpAddressIdToDeliveries to AddIPAddressIdToDeliveries (with capital "IP").

The correct name is:

  • File: add_ip_address_id_to_deliveries.rb
  • Class: AddIPAddressIdToDeliveries (IP is acronym, Id is not)

The CI should now pass all tests successfully.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feat: add ip_address_id from ip_pools that is used to send message</issue_title>
<issue_description>When a message in table queued_message in main schema reach a final state (sent or hardfail), it should port ip_address_id in a new field of deliveries table of specific mail server schema.

Show the new field in detail page of a message.
</issue_description>

<agent_instructions>try to solve the issue, add db migration and then add test case</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 23, 2026 10:19
Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
…uery

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ip_address_id field to deliveries table Track IP address used for message delivery attempts Jan 23, 2026
Copilot AI requested a review from lucaforni January 23, 2026 10:28
@lucaforni
Copy link

@copilot fix CI pipeline to run db migration before starting tests. Then fix also initial database schema with added field

…ew fields

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot fix CI pipeline to run db migration before starting tests. Then fix also initial database schema with added field

Fixed in commit bf70063:

  1. CI Pipeline: Added bundle exec rails db:prepare step before running tests to ensure database migrations are executed
  2. Initial Schema: Updated the initial CreateDeliveries migration (03) to include both time and ip_address_id fields from the start
  3. Idempotent Migrations: Made migrations 11 and 21 check if columns exist before adding them, supporting both fresh installs and database upgrades

The changes ensure that:

  • Fresh database installations get the complete schema immediately
  • Existing databases can upgrade by running the incremental migrations
  • CI properly prepares the database before running tests

@lucaforni
Copy link

@copilot la CI va in errore, analizza e risolvi

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot la CI va in errore, analizza e risolvi

Risolto in commit 9f55a6b. C'erano due problemi:

  1. Nome della classe migration: La classe doveva chiamarsi AddIPAddressIDToDeliveries (con IP e ID in maiuscolo) invece di AddIpAddressIdToDeliveries per rispettare le convenzioni Rails per gli acronimi

  2. Setup dei test: Mancava la definizione di send_result e il mock dell'SMTP sender nel contesto dei test

La CI ora dovrebbe passare correttamente.

@lucaforni
Copy link

@copilot la CI continua a fallire, analizza e correggi

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot la CI continua a fallire, analizza e correggi

Risolto in commit 04660ac.

Il problema era nel setup dei test: stavo cercando di creare un'Organization con ip_pool: ip_pool, ma Organization ha una relazione many-to-many con IP pools attraverso organization_ip_pools.

Ho corretto creando prima l'organization separatamente, poi associando l'ip_pool usando organization.ip_pools << ip_pool nel blocco before.

La CI ora dovrebbe passare correttamente.

@lucaforni
Copy link

@copilot C'è ancora un problema con la CI

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot C'è ancora un problema con la CI

Risolto in commit 7a8b566.

Il problema era il nome della classe migration: stavo usando AddIPAddressIDToDeliveries (convenzione Rails per acronimi), ma il sistema di migrazione di MessageDB usa semplicemente .camelize sul nome del file, che produce AddIpAddressIdToDeliveries.

Ho corretto il nome della classe per corrispondere a quello che il migration loader si aspetta.

La CI ora dovrebbe passare correttamente.

@lucaforni
Copy link

@copilot c'è ancora un problema nella CI:

  1. Legacy Messages API /api/v1/messages/deliveries when the credential is valid when the message ID does not exist returns an error
    Failure/Error: klass = Postal::MessageDB::Migrations.const_get(klass_name)

    NameError:
    uninitialized constant Postal::MessageDB::Migrations::AddIPAddressIdToDeliveries

Co-authored-by: lucaforni <8351507+lucaforni@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot c'è ancora un problema nella CI:

  1. Legacy Messages API /api/v1/messages/deliveries when the credential is valid when the message ID does not exist returns an error
    Failure/Error: k...

Risolto in commit 662a9a5.

Il problema era che l'applicazione ha definito "IP" come acronimo in config/initializers/inflections.rb (linea 29: inflect.acronym "IP"). Questo significa che quando Rails chiama .camelize sul nome del file, "IP" viene mantenuto in maiuscolo.

Ho cambiato la classe da AddIpAddressIdToDeliveries a AddIPAddressIdToDeliveries (con "IP" maiuscolo, come richiesto dall'inflector).

La CI ora dovrebbe passare correttamente.

@lucaforni lucaforni marked this pull request as ready for review January 23, 2026 13:37
@lucaforni lucaforni merged commit b2a107f into main-modalsource Jan 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: add ip_address_id from ip_pools that is used to send message

2 participants