Now that we have identified the bug, it is time to patch it, test it, and then push it upstream.

In this scene, we are going to update the application code to eliminate the bug. Then we will commit our patch and run a couple tests to test it in our environment. Once we are satisfied with our tests, we will push our code upstream.

YOUR STEPS FOR THIS SCENE

  1. Bring VS Code to the foreground.
  2. Switch to the Explorer view (purple rectangle, below).
  3. Switch to the develop branch by clicking on master and then selecting develop from the dropdown list.


  4. Expand the sql_code/ddl folders (underlined, below) and then click the new file button (red circle, below)
  5. Name the new file something like add_constraint_to_username.sql


  6. In the new file, copy and paste one of the the following texts, then save the file.

    FOR Oracle

    ALTER TABLE USERS
     ADD CONSTRAINT username UNIQUE(username);
    

    FOR Postgres

    ALTER TABLE ONLY public.users 
         ADD CONSTRAINT username UNIQUE(username);
    


  7. Now let’s commit and push our change. Switch to the Source Control view (yellow box) and click the + (yellow circle) icon to add our changes


  8. Add a commit message and click the checkmark to apply the commit.


  9. Click the sync button (yellow rectangle) to push the changes. Click OK button, if prompted.


  10. As before, the push triggers a pipeline build for the develop branch.
  11. Once the pipeline job finishes, click the bookmark for the Patients Dev and test that you cannot add a duplicate user (like the previous scene)
  12. Once you validate the Patients Dev environment, let’s sync our changes and then merge to master, just like we did in Act II Scene I
  13. Now the master pipeline build runs in Jenkins. The build should be green and validate that the tests results all pass.



Git

  1. Go back to our ssh terminal and navigate to
    cd ~/git/app_repo/sql_code/ddl
    
  2. Checkout the develop branch
    git checkout develop
    
  3. Create a sql file and add one of the the following texts to it:

    FOR Oracle

    ALTER TABLE USERS
     ADD CONSTRAINT username UNIQUE(username);
    

    FOR Postgres

    ALTER TABLE ONLY public.users 
         ADD CONSTRAINT username UNIQUE(username);
    
  4. Save the file and exit the text editor


  5. Add the file to git, commit the file with a message, and then push the changes to git.
    git add add_constraint_to_username.sql
    git commit -m "username constraint"
    git push
    


  6. As before, the push triggers a pipeline build for the develop branch.
  7. Once the pipeline job finishes, click the bookmark for the Patients Dev and test that you cannot add a duplicate user (like the previous scene)
  8. Once you validate the Patients Dev environment, let’s sync our changes and then merge to master, just like we did in Act II Scene I
  9. Now the master pipeline build runs in Jenkins. The build should be green and validate that the tests results all pass.