Skip to content

Commit

Permalink
Merge pull request #462 from openedx/ammar/fix-migration
Browse files Browse the repository at this point in the history
feat: fix migrations
  • Loading branch information
muhammad-ammar authored Jul 18, 2024
2 parents 5ef321c + d800c5a commit dc89d50
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 15 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/mysql8-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Migrations check on mysql8

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
check_migrations:
name: check migrations
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04 ]
python-version: [ 3.8 ]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install system Packages
run: |
sudo apt-get update
- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip dependencies
id: cache-dependencies
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/pip_tools.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Ubuntu and sql Versions
run: |
lsb_release -a
mysql -V
- name: Install Python dependencies
run: |
pip install -r requirements/dev.txt
pip uninstall -y mysqlclient
pip install --no-binary mysqlclient mysqlclient
- name: Initiate Services
run: |
sudo /etc/init.d/mysql start
- name: Reset mysql password
run: |
cat <<EOF | mysql -h 127.0.0.1 -u root --password=root
UPDATE mysql.user SET authentication_string = null WHERE user = 'root';
FLUSH PRIVILEGES;
EOF
- name: Run migrations
env:
DATABASES: default
DB_ENGINE: django.db.backends.mysql
DB_USER: root
DB_PASSWORD: ""
DB_HOST: localhost
DB_PORT: 3306
run: |
echo "Running the migrations."
for db in $DATABASES;
do
echo "CREATE DATABASE IF NOT EXISTS db_$db;" | sudo mysql -u root
export DB_NAME=db_$db
python manage.py migrate --noinput --run-syncdb --database "$db" --settings=enterprise_data.settings.test
done
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Unreleased
----------

=========================
[8.0.0] - 2024-07-18
---------------------
* Fix migration for EnterpriseLearnerEnrollment model

[7.0.0] - 2024-07-12
---------------------
* Add new fields in EnterpriseLearnerEnrollment model
Expand Down
2 changes: 1 addition & 1 deletion enterprise_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Enterprise data api application. This Django app exposes API endpoints used by enterprises.
"""

__version__ = "7.0.0"
__version__ = "8.0.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.23 on 2024-07-12 07:40
# Generated by Django 3.2.23 on 2024-07-18 07:04

from django.db import migrations, models

Expand Down Expand Up @@ -29,13 +29,18 @@ class Migration(migrations.Migration):
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='lpr_unique_id',
field=models.PositiveBigIntegerField(default=enterprise_data.utils.get_unique_id, primary_key=True, serialize=False),
name='subscription_license_uuid',
field=models.UUIDField(null=True),
),
migrations.AlterField(
model_name='enterpriselearnerenrollment',
name='enterprise_enrollment_id',
field=models.PositiveIntegerField(unique=True),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='subscription_license_uuid',
field=models.UUIDField(null=True),
name='lpr_unique_id',
field=models.PositiveBigIntegerField(default=enterprise_data.utils.get_unique_id, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='enterpriselearnerenrollment',
Expand Down
17 changes: 8 additions & 9 deletions enterprise_data/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
In a real-world use case, apps in this project are installed into other
Django applications, so these settings will not be used.
"""


import os
from os.path import abspath, dirname, join

from enterprise_data_roles.constants import (
Expand All @@ -31,13 +30,13 @@ def root(*args):

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "default.db",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
}
"ENGINE": os.environ.get("DB_ENGINE", "django.db.backends.sqlite3"),
"NAME": os.environ.get("DB_NAME", "default.db"),
"USER": os.environ.get("DB_USER", ""),
"PASSWORD": os.environ.get("DB_PASS", ""),
"HOST": os.environ.get("DB_HOST", ""),
"PORT": os.environ.get("DB_PORT", ""),
},
}

INSTALLED_APPS = (
Expand Down

0 comments on commit dc89d50

Please sign in to comment.