mentorship-backend icon indicating copy to clipboard operation
mentorship-backend copied to clipboard

Dev: Add initial migration and Running migration instruction to README

Open mtreacy002 opened this issue 3 years ago • 2 comments

Description

Initiate migration script and add running migration script to README

Fixes #996

Type of Change:

  • Code
  • Documentation

Code/Quality Assurance Only

  • This change requires a documentation update (software upgrade on readme file)
  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  1. On initiation of migration script/when contributors running migration script for the first time Confirmed that alembic version was added to the local db and the initial version was created under migrations > versions folder before running initial migration Screen Shot 2021-07-07 at 2 11 46 pm Screen Shot 2021-07-07 at 2 37 27 pm

after running initial migration Screen Shot 2021-07-07 at 2 20 24 pm copy Screen Shot 2021-07-07 at 2 36 29 pm

  1. if contributor missed migration version updates Screen Shot 2021-07-07 at 3 51 11 pm

The local db will be updated one version at a time accordingly from initial to second revision Screen Shot 2021-07-07 at 2 24 37 pm

from second to third revision Screen Shot 2021-07-07 at 3 50 22 pm

  1. When you are making changes by adding attribute/s to an existing db model Screen Shot 2021-07-07 at 4 13 34 pm Screen Shot 2021-07-07 at 4 13 42 pm Screen Shot 2021-07-07 at 2 24 37 pm

  2. When you are making changes by ALTERING EXISTING ATTRIBUTES inside an existing db model Example case: User table Changes:

    • renaming column name to full_name
    • change password_hash field length from 100 to unspecified
Screen Shot 2021-07-09 at 10 53 07 pm

IMPORTANT Noticed that the auto-generated alembic script IS NOT CORRECT!!. You MUST MODIFY the script to reflect the intended schema changes. Once you're done, you can run flask db upgrade

Screen Shot 2021-07-09 at 11 37 04 pm

before alteration Screen Shot 2021-07-09 at 10 59 54 pm Screen Shot 2021-07-09 at 11 00 39 pm

After alteration (with data successfully preserved) Screen Shot 2021-07-09 at 11 34 41 pm Screen Shot 2021-07-09 at 11 34 56 pm

Checklist:

  • [ ] My PR follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code or materials
  • [ ] I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] Any dependent changes have been merged
  • [ ] Update Postman API at /docs folder
  • [ ] Update Swagger documentation and the exported file at /docs folder
  • [ ] Update requirements.txt

Code/Quality Assurance Only

  • [ ] My changes generate no new warnings
  • [ ] My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes
  • [ ] Any dependent changes have been published in downstream modules

ADDITIONAL NOTE NA

mtreacy002 avatar Jul 07 '21 06:07 mtreacy002

Codecov Report

Merging #1133 (21ec10c) into develop (d717c93) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head 21ec10c differs from pull request most recent head d0acedd. Consider uploading reports for the commit d0acedd to get more accurate results Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1133   +/-   ##
========================================
  Coverage    92.95%   92.95%           
========================================
  Files           38       38           
  Lines         2073     2073           
========================================
  Hits          1927     1927           
  Misses         146      146           
Impacted Files Coverage Δ
run.py 96.15% <100.00%> (ø)

codecov[bot] avatar Jul 07 '21 06:07 codecov[bot]

@isabelcosta, @epicadk, @vj-codes, this PR is now ready for a review. Look forward to your feedback 😉.

mtreacy002 avatar Jul 09 '21 14:07 mtreacy002