Here are steps to import posts from AirTable to FightPandemics database for different environments. These are posts meant to "bootstrap" our application with usable content for initial users, but will become less important over time.

A few notes:

  1. Get necessary private (*.pem) SSH keys from one of someone with AWS access leads for review/staging/production EC2 bastion instances (see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html on how to connect to EC2 with SSH)
  2. Connect to the desired environment:
    1. review:
      1. SSH in ssh -i ~/.ssh/fp-review-bastion.pem [ec2-user@3.92.4.126](<mailto:ec2-user@3.92.4.126>) & change directory to project cd FightPandemics
      2. Check out branch with changes to apply (or pull latest staging)
      3. Change directory to backend cd backend
      4. Import posts npm run import-posts -- -1 (if it fails because of a missing new dependency install that first npm i)
      5. You will see number of imported/inserted/failed post imports, see later for notes on errors
      6. Exit SSH
    2. staging:
      1. SSH in ssh -i ~/.ssh/fp-staging-bastion.pem [ec2-user@54.166.3.62](<mailto:ec2-user@54.166.3.62>) & change directory to project cd FightPandemics
      2. You should be on staging branch already (check git status), pull the latest changes git pull
      3. Change directory to backend cd backend
      4. Import posts npm run import-posts -- -1 (if it fails because of a missing new dependency install that first npm i)
      5. You will see number of imported/inserted/failed post imports, see later for notes on errors
      6. Exit SSH
    3. production:
      1. SSH into bastion ssh -i ~/.ssh/fp-production-bastion.pem [ec2-user@ec2-52-211-223-192.eu-west-1.compute.amazonaws.com](<mailto:ec2-user@ec2-52-211-223-192.eu-west-1.compute.amazonaws.com>)
      2. SSH to instance on private subnet ssh mongo-airtable & change directory to project cd FightPandemics
      3. You should be on production branch already (check git status), pull the latest changes git pull
      4. Change directory to backend cd backend
      5. Import posts npm run import-posts -- -1 (if it fails because of a missing new dependency install that first npm i)
      6. You will see number of imported/inserted/failed post imports, see later for notes on errors
      7. Exit SSH (twice)

Addressing Errors:

After running the script you will see details for posts that failed import and followed by an overall summary: e.g. Imported 3591 from Airtable in 30.137s. Inserted 0 new posts; updated 3591 existing posts. 23 posts failed to import.

Errors can occur due to:

  1. Being a mostly empty row - these can be ignored, e.g. `Cannot destructure property 'post_name' of 'post.field'``
  2. Empty title or content
  3. A post_type , post_needs or from_whom option was added not currently in the mapping
  4. A location was added that is not in the backend/scripts/import-posts/airtable-geocoded.json file

Items 2 & 3 require someone on the data collection team to update the post in AirTable.

Item 4 requires an updating of the file to include a geocoded location for that country/state/city combination.

As writing this, there haven't been new posts added to AirTable for many months and 23 unresolved errors (some belong to category 1 and should be ignored) so it is unclear if errors will need to be addressed in the future (since we are moving ever forward to more and more user added data).