Migration Copy Scripts
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from setup_django import *
|
||||
|
||||
from coord.models import Company as OldModel
|
||||
from transport.models import Company as NewModel
|
||||
|
||||
created = skipped = 0
|
||||
|
||||
for old in OldModel.objects.all():
|
||||
obj, was_created = NewModel.objects.get_or_create(
|
||||
id=old.id,
|
||||
defaults={
|
||||
"name": old.name,
|
||||
"contact_name": old.contact_name,
|
||||
"contact_number": old.contact_number,
|
||||
"contact_mobile": old.contact_mobile,
|
||||
"contact_email": old.contact_email,
|
||||
"address": old.address,
|
||||
"suburb_id": old.suburb_id,
|
||||
"notes": old.notes,
|
||||
}
|
||||
)
|
||||
|
||||
if was_created:
|
||||
created += 1
|
||||
else:
|
||||
skipped += 1
|
||||
|
||||
print(f"Companies — created: {created}, skipped: {skipped}")
|
||||
print("Companies:", OldModel.objects.count(), NewModel.objects.count())
|
||||
Reference in New Issue
Block a user