anitab-org / mentorship-backend

Mentorship System is an application that matches women in tech to mentor each other, on career development, through 1:1 relations during a certain period of time. This is the backend of this system.
https://mentorship-backend-temp.herokuapp.com/
GNU General Public License v3.0
196 stars 449 forks source link

Dev: Add initial migration and Running migration instruction to README #1133

Open mtreacy002 opened 3 years ago

mtreacy002 commented 3 years ago

Description

Initiate migration script and add running migration script to README

Fixes #996

Type of Change:

Code/Quality Assurance Only

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:

Code/Quality Assurance Only

ADDITIONAL NOTE NA

codecov[bot] commented 3 years ago

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%> (ø)
mtreacy002 commented 3 years ago

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