Skip to content

Commit

Permalink
Merge pull request #723 from sainAk/issue-719
Browse files Browse the repository at this point in the history
fix qr_code_id migration
  • Loading branch information
vigneshhari authored Apr 21, 2022
2 parents d39825d + cd65f62 commit f71b399
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions care/facility/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from djqscsv import render_to_csv_response

from care.facility.models.ambulance import Ambulance, AmbulanceDriver
from care.facility.models.asset import Asset
from care.facility.models.bed import AssetBed
from care.facility.models.patient_sample import PatientSample
from care.facility.models.patient_tele_consultation import PatientTeleConsultation
Expand Down Expand Up @@ -209,3 +210,4 @@ class FacilityUserAdmin(DjangoQLSearchMixin, admin.ModelAdmin, ExportCsvMixin):
admin.site.register(PatientInvestigation, PatientTestAdmin)
admin.site.register(PatientInvestigationGroup, PatientTestGroupAdmin)
admin.site.register(AssetBed)
admin.site.register(Asset)
12 changes: 10 additions & 2 deletions care/facility/migrations/0287_asset_qr_code_id.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Generated by Django 2.2.11 on 2022-04-21 17:33
# Generated by Django 2.2.11 on 2022-04-21 20:08
import uuid

import care.facility.models.asset
from django.db import migrations, models


def populate_empty_qr_code_id(apps, schema_editor):
Asset = apps.get_model("facility", "Asset")
for asset in Asset.objects.all():
asset.qr_code_id = uuid.uuid4()
asset.save()

class Migration(migrations.Migration):

dependencies = [
Expand All @@ -14,6 +21,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='asset',
name='qr_code_id',
field=models.CharField(blank=True, default=care.facility.models.asset.get_random_asset_id, max_length=1024, unique=True),
field=models.CharField(blank=True, default=care.facility.models.asset.get_random_asset_id, max_length=1024),
),
migrations.RunPython(populate_empty_qr_code_id, migrations.RunPython.noop),
]
19 changes: 19 additions & 0 deletions care/facility/migrations/0288_auto_20220422_0206.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.11 on 2022-04-21 20:36

import care.facility.models.asset
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('facility', '0287_asset_qr_code_id'),
]

operations = [
migrations.AlterField(
model_name='asset',
name='qr_code_id',
field=models.CharField(blank=True, default=care.facility.models.asset.get_random_asset_id, max_length=1024, unique=True),
),
]

0 comments on commit f71b399

Please sign in to comment.