11.4 Procedure A: same-dimension switch

Use when: the new model produces vectors of the same dimension as the old one. Examples:

No code or schema changes are required. The whole procedure is config + restart.

  1. Back up the database.
    sudo systemctl stop ownsona.service
    pg_dump -h localhost -U ownsona ownsona > /var/backups/ownsona-pre-reembed-$(date +%F).sql
    sudo systemctl start ownsona.service
    

    (Or rely on your nightly backup — but a fresh dump immediately before re-embed is safer.)

  2. Edit the deployed application.ini at <tomcat>/webapps/ROOT/WEB-INF/backend/application.ini:
    EMBEDDING_PROVIDER   = openai
    EMBEDDING_MODEL      = text-embedding-3-large
    EMBEDDING_DIMENSIONS = 1536
    EMBEDDING_API_KEY    = sk-...                # if it changed
    EMBEDDING_ENDPOINT   = https://api.openai.com/v1/embeddings
    
    REEMBED_ON_STARTUP   = true
    
  3. Restart the service.
    sudo systemctl restart ownsona.service
    
  4. Watch the log.
    journalctl -u ownsona.service -f
    

    You’ll see, in order:

    migrator: db_version at N, target N, nothing to apply
    record_migrator: done upgraded=0 failed=0
    reembed: starting active_provider=... active_model=... dims=...
    reembed: progress count=50
    reembed: progress count=100
    ...
    reembed: done count=N
    ApplicationIniWriter: set REEMBED_ON_STARTUP = false in <path>
    

    The server is serving requests during the walker’s run. Recall on rows already updated uses new-model vectors; recall on rows not yet updated uses old-model vectors. Within either cohort, results are correct; across cohorts, scores are not meaningfully comparable. For a single-user store this window is minutes, not hours.

  5. Verify and propagate.
    SELECT embedding_provider, embedding_model, count(*)
    FROM memories
    GROUP BY 1, 2;
    

    Should show one row, with the new provider/model and a count matching count(*) overall.

    The walker auto-flips REEMBED_ON_STARTUP=false in the deployed application.ini, but the source tree still has it at true. Before your next WAR build, update src/main/backend/application.ini (and the example file) to match, so the next deploy doesn’t accidentally re-trigger the walker.