Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check any migrations change #33636

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft

Check any migrations change #33636

wants to merge 16 commits into from

Conversation

awais786
Copy link
Contributor

@awais786 awais786 commented Nov 1, 2023

Just a POC to identify any new migrations coming from edx-platform or any sitepackages.

Upgrade package has 2 migrations.

Added new workflow.

  • In first step checkout master branch.
  • Run makemigrations and migrate command.
  • Get django_migrations table count.

Now checkout current branch.

  • Run makemigrations and migrate command.
  • Get django_migrations count.

If there any difference between run this select name from django_migrations ORDER by -id limit $diff and share as comment on PR.

@awais786 awais786 changed the title Check migrations Check any migrations change Nov 1, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
author Awais Qureshi <[email protected]> 1698834786 +0500
committer Awais Qureshi <[email protected]> 1701168550 +0500

build: capturing added or remove migrations.

build: capturing added or remove migrations.

build: capturing added or remove migrations.

build: capturing added or remove migrations.

build: capturing added or remove migrations.

build: upgrading pillow.

chore: fixing test.

chore: minor change.

chore: minor change.

feat: Upgrade Python dependency social-auth-app-django (#33826)

Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master`

Co-authored-by: awais786 <[email protected]>

chore: minor change.
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
Copy link
Contributor

github-actions bot commented Nov 28, 2023

Migrations added in this PR.

  • 0003_alter_historicalusersocialauth_id
  • 0011_alter_id_fields

@openedx openedx deleted a comment from github-actions bot Nov 28, 2023
run: |
pip freeze

- name: Run Tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be renamed, since it doesn't actually run any tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

STUDIO_CFG: lms/envs/minimal.yml
run: |
echo "Running the LMS migrations."
./manage.py lms makemigrations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here to catch any code changes which should create migrations, but the author forgot to add them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

diff=$((number2 - number1))
if [ $number2 -gt $number1 ]; then
data=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select name from django_migrations ORDER by -id limit $diff;" edxapp;)
echo "$data" > cleaned_data.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the "Migrations added in this PR." text that appeared in the comment, did I miss that or was it removed over the course of code edits?

number1=${{ env.FIRST_QUERY }}
diff=$((number2 - number1))
if [ $number2 -gt $number1 ]; then
data=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select name from django_migrations ORDER by -id limit $diff;" edxapp;)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also select and display app_label so it's clear where each migration came from.

Copy link
Contributor

github-actions bot commented Jan 22, 2024

app name
support 0003_alter_historicalusersocialauth_id
social_django 0011_alter_id_fields

@awais786
Copy link
Contributor Author

All changes done.

Copy link
Contributor

@dianakhuang dianakhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a POC, but I would love to make the comments more useful so we can merge this.

diff=$((number2 - number1))
if [ $number2 -gt $number1 ]; then
data=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select app, name from django_migrations ORDER by -id limit $diff;" edxapp;)
echo "$data" > cleaned_data.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding to what Jeremy said earlier. I appreciate the app name and tables being added to the output, but I think it would be useful to have the text saying 'Migrations added in this PR' so that reviewers have that context. I would also maybe add some text asking the reviewers to do things like check to make sure it won't break blue-green deployments.

data=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select app, name from django_migrations ORDER by -id limit $diff;" edxapp;)
echo "$data" > cleaned_data.txt
elif [ $number1 -gt $number2 ]; then
echo "Your PR removed migrations." > cleaned_data.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think similar to above, maybe adding some lines about why it might be dangerous to remove migrations would help give this comment more context.

Copy link
Contributor

github-actions bot commented Feb 1, 2024

app name
support 0003_alter_historicalusersocialauth_id
social_django 0011_alter_id_fields

Copy link
Contributor

github-actions bot commented Feb 5, 2024

Migrations added in this PR
app name
support 0003_alter_historicalusersocialauth_id
social_django 0011_alter_id_fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants