Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collapse pco sub-orgs' briefingt/qpnotes records under pco #1342

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
36 changes: 36 additions & 0 deletions bin/migrate/migrate_briefingt_2022_12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
# coding=utf-8

"""
migration script to copy all briefingt records
for PCO sub-organizations into PCO organization
"""

import unicodecsv
import sys
import codecs


sub_orgs = [ 'ghl-lgc',
'iga-aig',
'mdi-mid',
'miga-maig',
'dpm-vmp',
'pkcc-pcprc',
'ql-lq',
'srp-rsp',
]
PCO = { 'owner_org': 'pco-bcp',
'owner_org_title': 'Privy Council Office | Bureau du Conseil privé' }

assert sys.stdin.read(3) == codecs.BOM_UTF8

in_csv = unicodecsv.DictReader(sys.stdin, encoding='utf-8')
out_csv = unicodecsv.DictWriter(sys.stdout, fieldnames=in_csv.fieldnames, encoding='utf-8')
out_csv.writeheader()

for line in in_csv:
if line['owner_org'] in sub_orgs:
line['owner_org'] = PCO['owner_org']
line['owner_org_title'] = PCO['owner_org_title']
RabiaSajjad marked this conversation as resolved.
Show resolved Hide resolved
out_csv.writerow(line)
36 changes: 36 additions & 0 deletions bin/migrate/migrate_qpnotes_2022_12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
# coding=utf-8

"""
migration script to copy all qpnotes records
for PCO sub-organizations into PCO organization
"""

import unicodecsv
import sys
import codecs


sub_orgs = [ 'ghl-lgc',
'iga-aig',
'mdi-mid',
'miga-maig',
'dpm-vmp',
'pkcc-pcprc',
'ql-lq',
'srp-rsp',
]
PCO = { 'owner_org': 'pco-bcp',
'owner_org_title': 'Privy Council Office | Bureau du Conseil privé' }

assert sys.stdin.read(3) == codecs.BOM_UTF8

in_csv = unicodecsv.DictReader(sys.stdin, encoding='utf-8')
out_csv = unicodecsv.DictWriter(sys.stdout, fieldnames=in_csv.fieldnames, encoding='utf-8')
out_csv.writeheader()

for line in in_csv:
if line['owner_org'] in sub_orgs:
line['owner_org'] = PCO['owner_org']
line['owner_org_title'] = PCO['owner_org_title']
out_csv.writerow(line)