Migrate missing KOMs
* special treatment for missing KOMs which could not be migrated due to wrong referencing in old database
This commit is contained in:
parent
34ab63e903
commit
9c978f0cbf
@ -16,7 +16,72 @@ class CompensationMigrater(BaseMigrater):
|
||||
def migrate(self):
|
||||
self.connect_db()
|
||||
cursor = self.db_connection.cursor()
|
||||
#el = "'KOM-1568808121948'" # Test purposes
|
||||
#el = "'KOM-1011-075001000051090029__'" # Test purposes
|
||||
els = [
|
||||
"\'KOM-31-3b-075003000006300002__\'",
|
||||
"\'KOM-38/12-075001000032000008__\'",
|
||||
"\'KOM-38/16-075001000032570001__\'",
|
||||
"\'KOM-38/18-07500100003196______\'",
|
||||
"\'KOM-38/17-07500100003202______\'",
|
||||
"\'KOM-38/14-075001000031670010__\'",
|
||||
"\'KOM-38/11-075001000031520001__\'",
|
||||
"\'KOM-38/10-075001000031390004__\'",
|
||||
"\'KOM-38/13-075001000031560004__\'",
|
||||
"\'KOM-38/15-075001000032320001__\'",
|
||||
"\'KOM-31-3b-07500300000630______\'",
|
||||
"\'KOM-31-3b-075003000006300003__\'",
|
||||
"\'KOM-31-3b-075003000006160005__\'",
|
||||
"\'KOM-31-3b-07500300000629______\'",
|
||||
"\'KOM-24-1b-07500900000909______\'",
|
||||
"\'KOM-24-1b-075009000009090002__\'",
|
||||
"\'KOM-24-1c-07500900000890______\'",
|
||||
"\'KOM-24-1e-075009000009070001__\'",
|
||||
"\'KOM-24-9-075009000009190002__\'",
|
||||
"\'KOM-31-3b-075003000006160002__\'",
|
||||
"\'KOM-24-1b-075009000009380007__\'",
|
||||
"\'KOM-24-1c-07500900000904______\'",
|
||||
"\'KOM-24-1c-07500900000903______\'",
|
||||
"\'KOM-36-2-075001000044750002__\'",
|
||||
"\'KOM-31-3b-075003000006160004__\'",
|
||||
"\'KOM-31-3b-07500300000616______\'",
|
||||
"\'KOM-31-2-075003000006830001__\'",
|
||||
"\'KOM-24-1c-075009000009380020__\'",
|
||||
"\'KOM-24-1c-07500900000906______\'",
|
||||
"\'KOM-24-1c-07500900000894______\'",
|
||||
"\'KOM-36-1-075001000044750009__\'",
|
||||
"\'KOM-24-1c-07500900000891______\'",
|
||||
"\'KOM-22-2-075009000009650001__b\'",
|
||||
"\'KOM-100-075001000031810001__\'",
|
||||
"\'KOM-24-9-075009000009380027__\'",
|
||||
"\'KOM-24-9-07500900000919______\'",
|
||||
"\'KOM-24-9-075009000009170002__\'",
|
||||
"\'KOM-31-3b-075003000006160003__\'",
|
||||
"\'KOM-1011-075001000051090029__\'",
|
||||
"\'KOM-1010-075001000036370001__\'",
|
||||
"\'KOM-50/3-075001000037300001__\'",
|
||||
"\'KOM-50/2-075001000037300001__\'",
|
||||
"\'KOM-50/1-07500100003725______\'",
|
||||
"\'KOM-A4-075004000012160279__\'",
|
||||
"\'KOM-52-07500100003724______\'",
|
||||
"\'KOM-1012-075001000036420012__\'",
|
||||
"\'KOM-KaEINS2_AN1-075001000036710042__\'",
|
||||
"\'KOM-KaEINS2_AN3-075001000036710042__\'",
|
||||
"\'KOM-KaEINS2_E8-075009000009460002__\'",
|
||||
"\'KOM-KaEINS2_E2_E3-075004000009450004__\'",
|
||||
"\'KOM-KaEINS2_E4-075001000039540001__a\'",
|
||||
"\'KOM-KaEINS2_E1-075001000037520001__\'",
|
||||
"\'KOM-KaEINS2_E5-075001000036910003__\'",
|
||||
"\'KOM-KaEINS2_E9-075001000039540001__\'",
|
||||
"\'KOM-KaEINS2_E6-075009000009480001__\'",
|
||||
"\'KOM-KAEINS2_AN6_V6-075001000036710042__\'",
|
||||
"\'KOM-KaEINS2_AN2-075001000036710042__\'",
|
||||
"\'KOM-KaEins2_AN4_A1_KM1-075001000036710042__\'",
|
||||
"\'KOM-KaEINS2_AN5_A4-075001000036710042__\'",
|
||||
"\'KOM-KaEINS2_E7-075009000009650001__\'",
|
||||
"\'KOM-KaEINS2_E3-075004000009280006_\'",
|
||||
]
|
||||
els = ",".join(els)
|
||||
els = f"({els})"
|
||||
empty_str = "''"
|
||||
cursor.execute(
|
||||
'select '
|
||||
@ -37,7 +102,8 @@ class CompensationMigrater(BaseMigrater):
|
||||
'om."OKL"=7730080 and '
|
||||
'om.archiv=false and '
|
||||
f'(auf."Infos" is null or auf."Infos"={empty_str}) and '
|
||||
'om.nicht_vollstaendig=0 '
|
||||
'om.nicht_vollstaendig=0 and '
|
||||
f'om."KENNUNG" in {els}'
|
||||
)
|
||||
|
||||
all_koms = cursor.fetchall()
|
||||
@ -58,30 +124,30 @@ class CompensationMigrater(BaseMigrater):
|
||||
identifier=kom_identifier
|
||||
)[0]
|
||||
|
||||
#compensation.title = kom_title
|
||||
#compensation.comment = kom_comment
|
||||
compensation.title = kom_title
|
||||
compensation.comment = kom_comment
|
||||
### FOR INITIAL RECONSTRUCTION OF EIV-KOM RELATIONSHIP
|
||||
#try:
|
||||
# compensation = self._migrate_interventions_reference(compensation, kom)
|
||||
#except ObjectDoesNotExist:
|
||||
# compensation.delete()
|
||||
# unsuccessfull_compensations[kom_identifier] = "EIV does not exist"
|
||||
# continue
|
||||
try:
|
||||
compensation = self._migrate_interventions_reference(compensation, kom)
|
||||
except ObjectDoesNotExist:
|
||||
compensation.delete()
|
||||
unsuccessfull_compensations[kom_identifier] = "EIV does not exist"
|
||||
continue
|
||||
|
||||
#compensation = self._migrate_par_7_data(compensation, kom)
|
||||
#compensation = self._migrate_responsibility(compensation, kom)
|
||||
#compensation = self._migrate_compensation_type(compensation, kom)
|
||||
#compensation = self._migrate_states(compensation, kom)
|
||||
#compensation = self._migrate_deadlines(compensation, kom)
|
||||
#compensation = self._migrate_action_control_deadlines(compensation, kom)
|
||||
#compensation = self._migrate_actions(compensation, kom)
|
||||
#compensation = self._migrate_log(compensation, kom)
|
||||
compensation = self._migrate_par_7_data(compensation, kom)
|
||||
compensation = self._migrate_responsibility(compensation, kom)
|
||||
compensation = self._migrate_compensation_type(compensation, kom)
|
||||
compensation = self._migrate_states(compensation, kom)
|
||||
compensation = self._migrate_deadlines(compensation, kom)
|
||||
compensation = self._migrate_action_control_deadlines(compensation, kom)
|
||||
compensation = self._migrate_actions(compensation, kom)
|
||||
compensation = self._migrate_log(compensation, kom)
|
||||
compensation = self._migrate_documents(compensation, CompensationDocument, kom)
|
||||
compensation.save()
|
||||
num_processed += 1
|
||||
|
||||
#compensation = self._migrate_geometry(compensation, kom)
|
||||
#compensation.save()
|
||||
compensation = self._migrate_geometry(compensation, kom)
|
||||
compensation.save()
|
||||
#print("The following KOMs could not be migrated: ")
|
||||
#for kom, val in unsuccessfull_compensations.items():
|
||||
# print(kom)
|
||||
@ -107,7 +173,7 @@ class CompensationMigrater(BaseMigrater):
|
||||
eiv = eivs[0]
|
||||
try:
|
||||
intervention = Intervention.objects.get(
|
||||
identifier=eiv[0]
|
||||
identifier__iexact=eiv[0]
|
||||
)
|
||||
except ObjectDoesNotExist:
|
||||
raise ObjectDoesNotExist(f"{kom_identifier} could not find migrated {eiv}")
|
||||
|
@ -19,10 +19,10 @@ class Command(BaseKonovaCommand):
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
migraters = [
|
||||
InterventionMigrater(options),
|
||||
#InterventionMigrater(options),
|
||||
CompensationMigrater(options),
|
||||
EmaMigrater(options),
|
||||
EcoAccountMigrater(options),
|
||||
#EmaMigrater(options),
|
||||
#EcoAccountMigrater(options),
|
||||
#InterventionRecordedMigrater(options),
|
||||
#UserMigrater(options),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user