Pointing ECS Cluster to Another DB Cluster

Overview

At times there's a need to point the FOLIO ECS cluster to another database. Doing this involves multiple steps.

Steps

  1. Make sure that at least the relevant modules in the workflow(s) that we want to test are the same between the two environments (the one whose database we're pointing to).  This is required because the databsae's deployment table stores the specific URLs of the modules that have version numbers in it.  This table is read by Okapi. If the docker containers do not have the versions listed in the database, failures likely to occur.  
    1. Action: compare version numbers of relevant modules. Deploy and enable them on the current environment if needed.  For example, if the cluster A is going to point to the cluster B's database, make sure that cluster A has the docker containers that cluster B is using because cluster B's database has records of them.
  2. Create the (new) database server from the snapshot of the database that we want to point to (henceforth it's cluster "B").  
  3. In the new database server:
    1. Update the password on the new database server to match that of the cluster A.
    2. Update the modules LB's addresses in the new database server.
      1. UPDATE public.deployments
        SET json=replace(json::text, 'B', 'A')::jsonb;
    3. Update the institutional users' credentials to match those of the cluster A
          In the starting DB (A), find the institutional user's UUID by username "<tenanId>, verify that it has the admin_inst permission
          Find the target DB (B/new database), find the institutional user by that UUID.  If it doesn't exist, add it.
          Find the institutional by UUID in mod_login.auth_credentials. Take the hash and salt from the starting DB and replace them in the target DB's table.
  4. Point the ECS cluster to the new DB in Route 53
  5. Restart Okapi