Document repair migration
* disables all migration parts despite document migration * running again with now fixed document migration handling, broken documents will be replaced with fixed ones
This commit is contained in:
parent
4f5c172449
commit
44e21f4ed9
@ -16,6 +16,7 @@ class CompensationMigrater(BaseMigrater):
|
|||||||
def migrate(self):
|
def migrate(self):
|
||||||
self.connect_db()
|
self.connect_db()
|
||||||
cursor = self.db_connection.cursor()
|
cursor = self.db_connection.cursor()
|
||||||
|
#el = "'KOM-1568808121948'" # Test purposes
|
||||||
empty_str = "''"
|
empty_str = "''"
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
'select '
|
'select '
|
||||||
@ -57,32 +58,33 @@ class CompensationMigrater(BaseMigrater):
|
|||||||
identifier=kom_identifier
|
identifier=kom_identifier
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
compensation.title = kom_title
|
#compensation.title = kom_title
|
||||||
compensation.comment = kom_comment
|
#compensation.comment = kom_comment
|
||||||
try:
|
### FOR INITIAL RECONSTRUCTION OF EIV-KOM RELATIONSHIP
|
||||||
compensation = self._migrate_interventions_reference(compensation, kom)
|
#try:
|
||||||
except ObjectDoesNotExist:
|
# compensation = self._migrate_interventions_reference(compensation, kom)
|
||||||
compensation.delete()
|
#except ObjectDoesNotExist:
|
||||||
unsuccessfull_compensations[kom_identifier] = "EIV does not exist"
|
# compensation.delete()
|
||||||
continue
|
# unsuccessfull_compensations[kom_identifier] = "EIV does not exist"
|
||||||
|
# continue
|
||||||
|
|
||||||
compensation = self._migrate_par_7_data(compensation, kom)
|
#compensation = self._migrate_par_7_data(compensation, kom)
|
||||||
compensation = self._migrate_responsibility(compensation, kom)
|
#compensation = self._migrate_responsibility(compensation, kom)
|
||||||
compensation = self._migrate_compensation_type(compensation, kom)
|
#compensation = self._migrate_compensation_type(compensation, kom)
|
||||||
compensation = self._migrate_states(compensation, kom)
|
#compensation = self._migrate_states(compensation, kom)
|
||||||
compensation = self._migrate_deadlines(compensation, kom)
|
#compensation = self._migrate_deadlines(compensation, kom)
|
||||||
compensation = self._migrate_action_control_deadlines(compensation, kom)
|
#compensation = self._migrate_action_control_deadlines(compensation, kom)
|
||||||
compensation = self._migrate_actions(compensation, kom)
|
#compensation = self._migrate_actions(compensation, kom)
|
||||||
compensation = self._migrate_log(compensation, kom)
|
#compensation = self._migrate_log(compensation, kom)
|
||||||
compensation = self._migrate_documents(compensation, CompensationDocument, kom)
|
compensation = self._migrate_documents(compensation, CompensationDocument, kom)
|
||||||
compensation.save()
|
compensation.save()
|
||||||
num_processed += 1
|
num_processed += 1
|
||||||
|
|
||||||
compensation = self._migrate_geometry(compensation, kom)
|
#compensation = self._migrate_geometry(compensation, kom)
|
||||||
compensation.save()
|
#compensation.save()
|
||||||
print("The following KOMs could not be migrated: ")
|
#print("The following KOMs could not be migrated: ")
|
||||||
for kom, val in unsuccessfull_compensations.items():
|
#for kom, val in unsuccessfull_compensations.items():
|
||||||
print(kom)
|
# print(kom)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
def _migrate_interventions_reference(self, compensation, kom):
|
def _migrate_interventions_reference(self, compensation, kom):
|
||||||
|
@ -21,7 +21,7 @@ from user.models import UserActionLogEntry
|
|||||||
class EcoAccountMigrater(CompensationMigrater):
|
class EcoAccountMigrater(CompensationMigrater):
|
||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
el = "'OEK-1488450234228'"
|
#el = "'OEK-1611234357085'" # Test purposes
|
||||||
self.connect_db()
|
self.connect_db()
|
||||||
cursor = self.db_connection.cursor()
|
cursor = self.db_connection.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
@ -61,25 +61,25 @@ class EcoAccountMigrater(CompensationMigrater):
|
|||||||
identifier=oek_identifier
|
identifier=oek_identifier
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
eco_account.title = oek_title
|
#eco_account.title = oek_title
|
||||||
eco_account.prevent_recording = False
|
#eco_account.prevent_recording = False
|
||||||
eco_account.comment = oek_comment
|
#eco_account.comment = oek_comment
|
||||||
eco_account = self._migrate_legal(eco_account, oek)
|
#eco_account = self._migrate_legal(eco_account, oek)
|
||||||
eco_account = self._migrate_states(eco_account, oek)
|
#eco_account = self._migrate_states(eco_account, oek)
|
||||||
eco_account = self._migrate_responsibility(eco_account, oek)
|
#eco_account = self._migrate_responsibility(eco_account, oek)
|
||||||
eco_account = self._migrate_deadlines(eco_account, oek)
|
#eco_account = self._migrate_deadlines(eco_account, oek)
|
||||||
eco_account = self._migrate_action_control_deadlines(eco_account, oek)
|
#eco_account = self._migrate_action_control_deadlines(eco_account, oek)
|
||||||
eco_account = self._migrate_actions(eco_account, oek)
|
#eco_account = self._migrate_actions(eco_account, oek)
|
||||||
eco_account = self._migrate_log(eco_account, oek)
|
#eco_account = self._migrate_log(eco_account, oek)
|
||||||
eco_account = self._migrate_recorded(eco_account, oek)
|
#eco_account = self._migrate_recorded(eco_account, oek)
|
||||||
eco_account = self._migrate_deductions(eco_account, oek)
|
#eco_account = self._migrate_deductions(eco_account, oek)
|
||||||
eco_account = self._migrate_documents(eco_account, EcoAccountDocument, oek)
|
eco_account = self._migrate_documents(eco_account, EcoAccountDocument, oek)
|
||||||
eco_account.save()
|
eco_account.save()
|
||||||
|
|
||||||
num_processed += 1
|
num_processed += 1
|
||||||
|
|
||||||
eco_account = self._migrate_geometry(eco_account, oek)
|
#eco_account = self._migrate_geometry(eco_account, oek)
|
||||||
eco_account.save()
|
#eco_account.save()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
def _migrate_geometry(self, instance, db_result: tuple):
|
def _migrate_geometry(self, instance, db_result: tuple):
|
||||||
|
@ -16,6 +16,7 @@ class EmaMigrater(CompensationMigrater):
|
|||||||
def migrate(self):
|
def migrate(self):
|
||||||
self.connect_db()
|
self.connect_db()
|
||||||
cursor = self.db_connection.cursor()
|
cursor = self.db_connection.cursor()
|
||||||
|
#el = "'EMA-1469083068361'" # Test purposes
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
'select '
|
'select '
|
||||||
'om."KENNUNG", '
|
'om."KENNUNG", '
|
||||||
@ -54,24 +55,24 @@ class EmaMigrater(CompensationMigrater):
|
|||||||
identifier=ema_identifier
|
identifier=ema_identifier
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
ema_obj.title = ema_title
|
#ema_obj.title = ema_title
|
||||||
ema_obj.comment = ema_comment
|
#ema_obj.comment = ema_comment
|
||||||
ema_obj = self._migrate_responsibility(ema_obj, ema)
|
#ema_obj = self._migrate_responsibility(ema_obj, ema)
|
||||||
ema_obj = self._migrate_compensation_type(ema_obj, ema)
|
#ema_obj = self._migrate_compensation_type(ema_obj, ema)
|
||||||
ema_obj = self._migrate_states(ema_obj, ema)
|
#ema_obj = self._migrate_states(ema_obj, ema)
|
||||||
ema_obj = self._migrate_deadlines(ema_obj, ema)
|
#ema_obj = self._migrate_deadlines(ema_obj, ema)
|
||||||
ema_obj = self._migrate_action_control_deadlines(ema_obj, ema)
|
#ema_obj = self._migrate_action_control_deadlines(ema_obj, ema)
|
||||||
ema_obj = self._migrate_actions(ema_obj, ema)
|
#ema_obj = self._migrate_actions(ema_obj, ema)
|
||||||
ema_obj = self._migrate_finance_volume_to_comment(ema_obj, ema)
|
#ema_obj = self._migrate_finance_volume_to_comment(ema_obj, ema)
|
||||||
ema_obj = self._migrate_log(ema_obj, ema)
|
#ema_obj = self._migrate_log(ema_obj, ema)
|
||||||
ema_obj = self._migrate_documents(ema_obj, EmaDocument, ema)
|
ema_obj = self._migrate_documents(ema_obj, EmaDocument, ema)
|
||||||
ema_obj = self._migrate_recorded(ema_obj, ema)
|
#ema_obj = self._migrate_recorded(ema_obj, ema)
|
||||||
ema_obj.save()
|
ema_obj.save()
|
||||||
|
|
||||||
num_processed += 1
|
num_processed += 1
|
||||||
|
|
||||||
ema_obj = self._migrate_geometry(ema_obj, ema)
|
#ema_obj = self._migrate_geometry(ema_obj, ema)
|
||||||
ema_obj.save()
|
#ema_obj.save()
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
self.connect_db()
|
self.connect_db()
|
||||||
el = "'EIV-1380625802430'"
|
#el = "'EIV-1613988897199'" # Test purposes
|
||||||
cursor = self.db_connection.cursor()
|
cursor = self.db_connection.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
'select '
|
'select '
|
||||||
@ -181,8 +181,7 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
'where '
|
'where '
|
||||||
'om."OKL"=7730085 and '
|
'om."OKL"=7730085 and '
|
||||||
'om.archiv=false and '
|
'om.archiv=false and '
|
||||||
'om.nicht_vollstaendig=0 and '
|
'om.nicht_vollstaendig=0'
|
||||||
f'om."KENNUNG"={el}'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
all_eivs = cursor.fetchall()
|
all_eivs = cursor.fetchall()
|
||||||
@ -209,7 +208,7 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
|
|
||||||
#intervention = self._migrate_geometry(intervention, eiv)
|
#intervention = self._migrate_geometry(intervention, eiv)
|
||||||
#intervention = self._migrate_intervention_payment(intervention, eiv)
|
#intervention = self._migrate_intervention_payment(intervention, eiv)
|
||||||
intervention.save()
|
#intervention.save()
|
||||||
|
|
||||||
num_processed += 1
|
num_processed += 1
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from konova.management.commands.setup import BaseKonovaCommand
|
|||||||
|
|
||||||
|
|
||||||
class Command(BaseKonovaCommand):
|
class Command(BaseKonovaCommand):
|
||||||
help = "Migrates from KSP database to Konova"
|
help = "Migrates from KSP to Konova"
|
||||||
db_connection = None
|
db_connection = None
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
@ -20,9 +20,9 @@ class Command(BaseKonovaCommand):
|
|||||||
try:
|
try:
|
||||||
migraters = [
|
migraters = [
|
||||||
InterventionMigrater(options),
|
InterventionMigrater(options),
|
||||||
#CompensationMigrater(options),
|
CompensationMigrater(options),
|
||||||
#EmaMigrater(options),
|
EmaMigrater(options),
|
||||||
#EcoAccountMigrater(options),
|
EcoAccountMigrater(options),
|
||||||
#InterventionRecordedMigrater(options),
|
#InterventionRecordedMigrater(options),
|
||||||
#UserMigrater(options),
|
#UserMigrater(options),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user