Normandy.Behaviours.SessionStore.Postgres.MigrationAddInflight (normandy v2.2.0)

View Source

Adds Normandy 2.0's in-flight index to normandy_sessions: the inflight column SessionStore.Postgres.save_turn_state/4 writes with the turn state, a partial index over the rows where it is true (list_resumable/1), and an index on head_id (delete_session/2 checks which entries another session still uses).

Call it from a host migration after the other Postgres.Migration* modules, and run it before 2.0 serves traffic: 2.0 reads and writes the column. The column has a default, so running it while 1.x nodes still serve is safe. Existing rows start with inflight = false: a session whose turn was in flight at the upgrade is not resumed by ResumeReaper until its next turn-state save (see MIGRATING-2.0 §40, "drain eager sessions before upgrading").

Summary

Functions

Drops the two indexes and removes the inflight column.

Adds the inflight boolean column (default false) to normandy_sessions, the partial index normandy_sessions_inflight_index over the rows where it is true, and an index on head_id. Run it after Migration and the other Migration* modules.

Functions

down()

Drops the two indexes and removes the inflight column.

up()

Adds the inflight boolean column (default false) to normandy_sessions, the partial index normandy_sessions_inflight_index over the rows where it is true, and an index on head_id. Run it after Migration and the other Migration* modules.