Skip to content

Commit 0dabaf9

Browse files
committed
Split database into current and legacy, adding importer to copy reused
tables from legacy to new through Django (with minimal cleaning to have the import go through) and removing migrations from submit and liaisons as they interfere with the clean slate of the new database, adjusting IPR model to add null=True on fields with nulls in the database - Legacy-Id: 3778
1 parent 5079d60 commit 0dabaf9

27 files changed

Lines changed: 415 additions & 2553 deletions

ietf/iesg/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def __unicode__(self):
9898
type_name = self.TYPE_CHOICES_DICT.get(self.type, str(self.type))
9999
return u'%s: %s' % (type_name, self.title or "")
100100
class Meta:
101-
db_table = 'templates'
101+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
102+
db_table = 'templates'
102103

103104
class WGAction(models.Model):
104105
CATEGORY_CHOICES = (
@@ -120,7 +121,8 @@ class WGAction(models.Model):
120121
def __str__(self):
121122
return str(self.telechat_date)+": "+str(self.group_acronym)
122123
class Meta:
123-
db_table = 'group_internal'
124+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
125+
db_table = 'group_internal'
124126
ordering = ['-telechat_date']
125127
verbose_name = "WG Action"
126128

ietf/ipr/models.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ class IprSelecttype(models.Model):
4545
def __str__(self):
4646
return self.type_display
4747
class Meta:
48-
db_table = 'ipr_selecttype'
48+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
49+
db_table = 'ipr_selecttype'
4950

5051
class IprLicensing(models.Model):
5152
licensing_option = models.AutoField(primary_key=True)
5253
value = models.CharField(max_length=255, db_column='licensing_option_value')
5354
def __str__(self):
5455
return self.value;
5556
class Meta:
56-
db_table = 'ipr_licensing'
57+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
58+
db_table = 'ipr_licensing'
5759

5860

5961
class IprDetail(models.Model):
@@ -87,15 +89,15 @@ class IprDetail(models.Model):
8789
date_applied = models.CharField(max_length=255)
8890
country = models.CharField(max_length=100)
8991
notes = models.TextField("Additional notes", db_column="p_notes", blank=True)
90-
is_pending = models.IntegerField("Unpublished Pending Patent Application", blank=True, choices=SELECT_CHOICES, db_column="selecttype")
91-
applies_to_all = models.IntegerField("Applies to all IPR owned by Submitter", blank=True, choices=SELECT_CHOICES, db_column="selectowned")
92+
is_pending = models.IntegerField("Unpublished Pending Patent Application", blank=True, null=True, choices=SELECT_CHOICES, db_column="selecttype")
93+
applies_to_all = models.IntegerField("Applies to all IPR owned by Submitter", blank=True, null=True, choices=SELECT_CHOICES, db_column="selectowned")
9294

9395
# Licensing Declaration fieldset
9496
#licensing_option = models.ForeignKey(IprLicensing, db_column='licensing_option')
9597
licensing_option = models.IntegerField(null=True, blank=True, choices=LICENSE_CHOICES)
96-
lic_opt_a_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
97-
lic_opt_b_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
98-
lic_opt_c_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
98+
lic_opt_a_sub = models.IntegerField(null=True, editable=False, choices=STDONLY_CHOICES)
99+
lic_opt_b_sub = models.IntegerField(null=True, editable=False, choices=STDONLY_CHOICES)
100+
lic_opt_c_sub = models.IntegerField(null=True, editable=False, choices=STDONLY_CHOICES)
99101
comments = models.TextField("Licensing Comments", blank=True)
100102
lic_checkbox = models.BooleanField("All terms and conditions has been disclosed")
101103

@@ -116,6 +118,9 @@ class IprDetail(models.Model):
116118
def __str__(self):
117119
return self.title
118120
def __unicode__(self):
121+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
122+
# the latin-1 decode doesn't seem necessary anymore
123+
return self.title
119124
return self.title.decode("latin-1", 'replace')
120125
def docs(self):
121126
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
@@ -132,7 +137,8 @@ def get_submitter(self):
132137
except IprContact.MultipleObjectsReturned:
133138
return self.contact.filter(contact_type=3)[0]
134139
class Meta:
135-
db_table = 'ipr_detail'
140+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
141+
db_table = 'ipr_detail'
136142

137143
class IprContact(models.Model):
138144
TYPE_CHOICES = (
@@ -154,7 +160,8 @@ class IprContact(models.Model):
154160
def __str__(self):
155161
return self.name or '<no name>'
156162
class Meta:
157-
db_table = 'ipr_contacts'
163+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
164+
db_table = 'ipr_contacts'
158165

159166

160167
class IprDraft(models.Model):
@@ -174,7 +181,8 @@ class IprNotification(models.Model):
174181
def __str__(self):
175182
return "IPR notification for %s sent %s %s" % (self.ipr, self.date_sent, self.time_sent)
176183
class Meta:
177-
db_table = 'ipr_notifications'
184+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
185+
db_table = 'ipr_notifications'
178186

179187
class IprRfc(models.Model):
180188
ipr = models.ForeignKey(IprDetail, related_name='rfcs_old' if settings.USE_DB_REDESIGN_PROXY_CLASSES else 'rfcs')
@@ -191,7 +199,8 @@ class IprUpdate(models.Model):
191199
status_to_be = models.IntegerField(null=True, blank=True)
192200
processed = models.IntegerField(null=True, blank=True)
193201
class Meta:
194-
db_table = 'ipr_updates'
202+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
203+
db_table = 'ipr_updates'
195204

196205

197206
if settings.USE_DB_REDESIGN_PROXY_CLASSES or hasattr(settings, "IMPORTING_IPR"):

ietf/legacy_router.py

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
class LegacyRouter(object):
2+
legacy_apps = ["idindex", "idtracker", "ietfauth", ""]
3+
legacy_models = ["AnnouncedFrom", "AnnouncedTo", "Announcement", "ScheduledAnnouncement",
4+
"TelechatDates"]
5+
6+
def db_for_read(self, model, **hints):
7+
if model._meta.db_table in legacy_tables:
8+
return 'legacy'
9+
return None
10+
11+
def db_for_write(self, model, **hints):
12+
if model._meta.db_table in legacy_tables:
13+
raise Exception("You can't write to the legacy table %s" % model._meta.db_table)
14+
return None
15+
16+
def allow_relation(self, obj1, obj2, **hints):
17+
if (obj1._meta.db_table in legacy_tables) != (obj2._meta.db_table in legacy_tables):
18+
return False
19+
return None
20+
21+
def allow_syncdb(self, db, model):
22+
if db == 'legacy':
23+
return False
24+
if model._meta.db_table in legacy_tables:
25+
return False
26+
return None
27+
28+
legacy_tables = set((
29+
"acronym",
30+
"agenda_cat",
31+
"agenda_items",
32+
"all_id",
33+
"announced_from",
34+
"announced_to",
35+
"announcements",
36+
"area_directors",
37+
"area_group",
38+
"area_status",
39+
"areas",
40+
"ballot_info",
41+
"ballots",
42+
"ballots_comment",
43+
"ballots_discuss",
44+
"bash_agenda",
45+
"chairs",
46+
"chairs_history",
47+
"document_comments",
48+
"draft_versions_mirror",
49+
"dt_request",
50+
"email_addresses",
51+
"from_bodies",
52+
"g_chairs",
53+
"g_editors",
54+
"g_secretaries",
55+
"g_secretary",
56+
"g_status",
57+
"g_tech_advisors",
58+
"g_type",
59+
"general_info",
60+
"goals_milestones",
61+
"group_flag",
62+
"group_internal",
63+
"groups_ietf",
64+
"hit_counter",
65+
"id_approved_detail",
66+
"id_authors",
67+
"id_dates",
68+
"id_intended_status",
69+
"id_internal",
70+
"id_restricted_word",
71+
"id_status",
72+
"id_submission_detail",
73+
"id_submission_env",
74+
"id_submission_status",
75+
"idst_users",
76+
"iesg_history",
77+
"iesg_login",
78+
"iesg_password",
79+
"iesg_telechatdate",
80+
"ietfauth_ietfuserprofile",
81+
"ietfauth_usermap",
82+
"ietfworkflows_annotationtag",
83+
"ietfworkflows_annotationtagobjectrelation",
84+
"ietfworkflows_objectannotationtaghistoryentry",
85+
"ietfworkflows_objecthistoryentry",
86+
"ietfworkflows_objectstreamhistoryentry",
87+
"ietfworkflows_objectworkflowhistoryentry",
88+
"ietfworkflows_statedescription",
89+
"ietfworkflows_stateobjectrelationmetadata",
90+
"ietfworkflows_stream",
91+
"ietfworkflows_streamdelegate",
92+
"ietfworkflows_streamedid",
93+
"ietfworkflows_wgworkflow",
94+
"ietfworkflows_wgworkflow_selected_states",
95+
"ietfworkflows_wgworkflow_selected_tags",
96+
"imported_mailing_list",
97+
"interim_info",
98+
"interim_meetings_acronym",
99+
"interim_meetings_groups_ietf",
100+
"interim_meetings_interim_info",
101+
"interim_meetings_interim_new",
102+
"interim_meetings_meetings",
103+
"interim_meetings_minutes",
104+
"interim_meetings_slides",
105+
"internet_drafts",
106+
"ipr_contacts",
107+
"ipr_detail",
108+
"ipr_ids",
109+
"ipr_licensing",
110+
"ipr_notifications",
111+
"ipr_rfcs",
112+
"ipr_selecttype",
113+
"ipr_updates",
114+
"irtf",
115+
"irtf_chairs",
116+
"liaison_detail",
117+
"liaison_detail_temp",
118+
"liaison_managers",
119+
"liaison_purpose",
120+
"liaisons_interim",
121+
"liaisons_members",
122+
"liaisons_outgoingliaisonapproval",
123+
"liaisons_sdoauthorizedindividual",
124+
"lists_email",
125+
"lists_email_refs",
126+
"lists_list",
127+
"mailing_list",
128+
"mailinglists_domain",
129+
"mailinglists_domain_approvers",
130+
"management_issues",
131+
"meeting_agenda_count",
132+
"meeting_attendees",
133+
"meeting_conflict",
134+
"meeting_conflict_groups",
135+
"meeting_hours",
136+
"meeting_rooms",
137+
"meeting_sessionstatusname",
138+
"meeting_times",
139+
"meeting_venues",
140+
"meetings",
141+
"messages",
142+
"migrate_stat",
143+
"minutes",
144+
"nomcom",
145+
"nomcom_members",
146+
"non_session",
147+
"non_session_ref",
148+
"none_wg_mailing_list",
149+
"not_meeting_groups",
150+
"old_document_comments",
151+
"outstanding_tasks",
152+
"permissions_objectpermission",
153+
"permissions_objectpermissioninheritanceblock",
154+
"permissions_permission",
155+
"permissions_permission_content_types",
156+
"permissions_principalrolerelation",
157+
"permissions_role",
158+
"person_or_org_info",
159+
"phone_numbers",
160+
"postal_addresses",
161+
"print_name",
162+
"prior_address",
163+
"proceedings",
164+
"pwg_cat",
165+
"ref_doc_states_new",
166+
"ref_next_states_new",
167+
"ref_resp",
168+
"replaced_ids",
169+
"request",
170+
"rfc_authors",
171+
"rfc_editor_queue_mirror",
172+
"rfc_editor_queue_mirror_refs",
173+
"rfc_index_mirror",
174+
"rfc_intend_status",
175+
"rfc_status",
176+
"rfcs",
177+
"rfcs_obsolete",
178+
"roll_call",
179+
"scheduled_announcements",
180+
"scheduled_announcements_temp",
181+
"sdo_chairs",
182+
"sdos",
183+
"secretariat_staff",
184+
"session_conflicts",
185+
"session_names",
186+
"session_request_activities",
187+
"session_status",
188+
"slide_types",
189+
"slides",
190+
"staff_work_detail",
191+
"staff_work_history",
192+
"sub_state",
193+
"switches",
194+
"task_status",
195+
"telechat",
196+
"telechat_dates",
197+
"telechat_minutes",
198+
"telechat_users",
199+
"temp_admins",
200+
"temp_agenda71166",
201+
"temp_id_authors",
202+
"temp_telechat_attendees",
203+
"temp_txt",
204+
"templates",
205+
"updated_ipr",
206+
"uploads",
207+
"uploads_temp",
208+
"users",
209+
"web_gm_chairs",
210+
"web_login_info",
211+
"web_user_info",
212+
"wg_agenda",
213+
"wg_meeting_sessions",
214+
"wg_meeting_sessions_temp",
215+
"wg_password",
216+
"wg_proceedings_activities",
217+
"wg_www_pages",
218+
"wgchairs_protowriteup",
219+
"wgchairs_wgdelegate",
220+
"workflows_state",
221+
"workflows_state_transitions",
222+
"workflows_stateinheritanceblock",
223+
"workflows_stateobjectrelation",
224+
"workflows_statepermissionrelation",
225+
"workflows_transition",
226+
"workflows_workflow",
227+
"workflows_workflowmodelrelation",
228+
"workflows_workflowobjectrelation",
229+
"workflows_workflowpermissionrelation",
230+
))
231+
232+

ietf/liaisons/migrations/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)