Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Django Oscar Upgrade to version 3.1 #4050

Merged
merged 15 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.20 on 2023-11-14 11:20

from django.core.paginator import Paginator
from django.db import migrations

Check warning on line 4 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L3-L4

Added lines #L3 - L4 were not covered by tests


def make_voucher_names_unique(apps, schema_editor):

Check warning on line 7 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L7

Added line #L7 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

@mumarkhan999 u also need to add test for this migration.

"""
Appends a number to voucher names.
"""
Voucher = apps.get_model('voucher', 'Voucher')
vouchers = Voucher.objects.order_by('date_created')
Copy link
Contributor

Choose a reason for hiding this comment

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

Total number of PROD records affected by this data migration

image

paginator = Paginator(vouchers, 1000)

Check warning on line 13 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L11-L13

Added lines #L11 - L13 were not covered by tests

for page_number in paginator.page_range:
page = paginator.page(page_number)
updates = []

Check warning on line 17 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L15-L17

Added lines #L15 - L17 were not covered by tests

for obj in page.object_list:
obj.name = '%d - %s' % (obj.id, obj.name)
updates.append(obj)

Check warning on line 21 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L19-L21

Added lines #L19 - L21 were not covered by tests

Voucher.objects.bulk_update(updates, ['name'])

Check warning on line 23 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L23

Added line #L23 was not covered by tests


class Migration(migrations.Migration):

Check warning on line 26 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L26

Added line #L26 was not covered by tests

dependencies = [

Check warning on line 28 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L28

Added line #L28 was not covered by tests
('voucher', '0012_voucher_is_public'),
]

operations = [

Check warning on line 32 in ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0013_make_voucher_names_unique.py#L32

Added line #L32 was not covered by tests
migrations.RunPython(make_voucher_names_unique, migrations.RunPython.noop),
]
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Generated by Django 3.2.20 on 2023-11-08 13:55
# Generated by Django 3.2.20 on 2023-11-14 11:56

from django.db import migrations, models

Check warning on line 3 in ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py#L3

Added line #L3 was not covered by tests


class Migration(migrations.Migration):

Check warning on line 6 in ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py#L6

Added line #L6 was not covered by tests

dependencies = [

Check warning on line 8 in ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py#L8

Added line #L8 was not covered by tests
('voucher', '0012_voucher_is_public'),
('voucher', '0013_make_voucher_names_unique'),
]

operations = [

Check warning on line 12 in ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/voucher/migrations/0014_auto_20231114_1156.py#L12

Added line #L12 was not covered by tests
migrations.AlterModelOptions(
name='voucher',
options={'get_latest_by': 'date_created', 'ordering': ['-date_created'], 'verbose_name': 'Voucher', 'verbose_name_plural': 'Vouchers'},
Expand Down
Loading