1
# Copyright 2005-2011 Canonical Ltd. All rights reserved.
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
from string import ascii_uppercase
18
from south.v2 import DataMigration
21
class Migration(DataMigration):
23
def forwards(self, orm):
24
"""Data migration for OOPS prefixes.
26
This data migration adds all prefixes needed by oops-tools tests.
32
for appinstance in appinstances_dict.keys():
33
for prefix in appinstances_dict[appinstance]:
34
a = orm.AppInstance.objects.get(title=appinstance)
35
# If the prefix doesn't exist in the database, then add it.
36
# This is to cope with the data already in the database added
37
# by the previous mechanism using initial_data.json
39
p = orm.Prefix.objects.get(value=prefix)
40
except orm.Prefix.DoesNotExist:
41
p = orm.Prefix(value=prefix, appinstance=a)
44
def backwards(self, orm):
45
raise RuntimeError("Can not reverse this migration.")
49
'Meta': {'object_name': 'AppInstance'},
50
'id': ('django.db.models.fields.AutoField', [],
51
{'primary_key': 'True'}),
52
'title': ('django.db.models.fields.CharField', [],
53
{'unique': 'True', 'max_length': '50'})
55
'oops.classification': {
56
'Meta': {'object_name': 'Classification'},
57
'id': ('django.db.models.fields.AutoField', [],
58
{'primary_key': 'True'}),
59
'title': ('django.db.models.fields.CharField', [],
60
{'unique': 'True', 'max_length': '100'})
62
'oops.dboopsrootdirectory': {
63
'Meta': {'object_name': 'DBOopsRootDirectory'},
64
'id': ('django.db.models.fields.AutoField', [],
65
{'primary_key': 'True'}),
66
'last_date': ('django.db.models.fields.DateField', [],
68
'last_oops': ('django.db.models.fields.CharField', [],
69
{'max_length': '200', 'null': 'True'}),
70
'root_dir': ('django.db.models.fields.CharField', [],
71
{'unique': 'True', 'max_length': '200'})
74
'Meta': {'unique_together':
75
"(('exception_type', 'exception_value'),)",
76
'object_name': 'Infestation'},
77
'bug': ('django.db.models.fields.PositiveIntegerField', [],
79
'exception_type': ('django.db.models.fields.CharField', [],
80
{'max_length': '100'}),
81
'exception_value': ('django.db.models.fields.CharField', [],
82
{'max_length': '1000'}),
83
'id': ('django.db.models.fields.AutoField', [],
84
{'primary_key': 'True'}),
87
'Meta': {'object_name': 'Oops'},
88
'appinstance': ('django.db.models.fields.related.ForeignKey', [],
89
{'to': "orm['oops.AppInstance']"}),
90
'classification': ('django.db.models.fields.related.ForeignKey', [],
91
{'to': "orm['oops.Classification']", 'null': 'True'}),
92
'date': ('django.db.models.fields.DateTimeField', [],
93
{'db_index': 'True'}),
94
'duration': ('django.db.models.fields.FloatField', [],
96
'http_method': ('django.db.models.fields.CharField', [],
97
{'max_length': '10', 'null': 'True'}),
98
'id': ('django.db.models.fields.AutoField', [],
99
{'primary_key': 'True'}),
100
'informational': ('django.db.models.fields.NullBooleanField', [],
102
'is_bot': ('django.db.models.fields.NullBooleanField', [],
103
{'null': 'True', 'db_index': 'True'}),
104
'is_local_referrer': ('django.db.models.fields.NullBooleanField', [],
105
{'null': 'True', 'db_index': 'True'}),
106
'most_expensive_statement': ('django.db.models.fields.CharField', [],
107
{'max_length': '200', 'null': 'True', 'db_index': 'True'}),
108
'oopsid': ('django.db.models.fields.CharField', [],
109
{'unique': 'True', 'max_length': '200'}),
110
'oopsinfestation': ('django.db.models.fields.related.ForeignKey', [],
111
{'to': "orm['oops.Infestation']"}),
112
'pageid': ('django.db.models.fields.CharField', [],
113
{'max_length': '500'}),
114
'pathname': ('django.db.models.fields.CharField', [],
115
{'unique': 'True', 'max_length': '200'}),
116
'prefix': ('django.db.models.fields.related.ForeignKey', [],
117
{'to': "orm['oops.Prefix']"}),
118
'referrer': ('django.db.models.fields.URLField', [],
119
{'max_length': '500', 'null': 'True'}),
120
'statements_count': ('django.db.models.fields.PositiveIntegerField', [],
122
'time_is_estimate': ('django.db.models.fields.NullBooleanField', [],
124
'total_time': ('django.db.models.fields.PositiveIntegerField', [],
126
'url': ('django.db.models.fields.URLField', [],
127
{'max_length': '500', 'null': 'True', 'db_index': 'True'}),
128
'user_agent': ('django.db.models.fields.CharField', [],
129
{'max_length': '200', 'null': 'True'})
132
'Meta': {'object_name': 'Prefix'},
133
'appinstance': ('django.db.models.fields.related.ForeignKey', [],
134
{'to': "orm['oops.AppInstance']"}),
135
'id': ('django.db.models.fields.AutoField', [],
136
{'primary_key': 'True'}),
137
'value': ('django.db.models.fields.CharField', [],
138
{'unique': 'True', 'max_length': '20'})
141
'Meta': {'object_name': 'Project'},
142
'id': ('django.db.models.fields.AutoField', [],
143
{'primary_key': 'True'}),
144
'title': ('django.db.models.fields.CharField', [],
145
{'unique': 'True', 'max_length': '200'})
149
complete_apps = ['oops']