~lifeless/python-oops-tools/bug-881400

« back to all changes in this revision

Viewing changes to src/oopstools/oops/migrations/0011_initial_classifications.py

  • Committer: Robert Collins
  • Date: 2011-10-13 20:18:51 UTC
  • Revision ID: robertc@robertcollins.net-20111013201851-ym8jmdhoeol3p83s
Export of cruft-deleted tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2005-2011 Canonical Ltd.  All rights reserved.
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
 
 
16
from south.v2 import DataMigration
 
17
 
 
18
 
 
19
class Migration(DataMigration):
 
20
 
 
21
    def forwards(self, orm):
 
22
        """Add Classification objects into the database."""
 
23
 
 
24
        classifications = (
 
25
            "Time Outs", "Soft Time Outs", "Informational Only Errors",
 
26
            "User Generated Errors", "Unauthorized Errors", "Pages Not Found",
 
27
             "Remote Checkwatches Warnings", "Remote Errors")
 
28
        for classification in classifications:
 
29
            # If the classification doesn't exist in the database, then add it.
 
30
            # This is to cope with the data already in the database added by
 
31
            # the previous mechanism using initial_data.json
 
32
            try:
 
33
                c = orm.Classification.objects.get(title=classification)
 
34
            except orm.Classification.DoesNotExist:
 
35
                c = orm.Classification(title=classification)
 
36
            c.save()
 
37
 
 
38
    def backwards(self, orm):
 
39
        raise RuntimeError("Can not reverse this migration.")
 
40
 
 
41
    models = {
 
42
        'oops.appinstance': {
 
43
            'Meta': {'object_name': 'AppInstance'},
 
44
            'id': ('django.db.models.fields.AutoField', [],
 
45
                {'primary_key': 'True'}),
 
46
            'title': ('django.db.models.fields.CharField', [],
 
47
                {'unique': 'True', 'max_length': '50'})
 
48
        },
 
49
        'oops.classification': {
 
50
            'Meta': {'object_name': 'Classification'},
 
51
            'id': ('django.db.models.fields.AutoField', [],
 
52
                {'primary_key': 'True'}),
 
53
            'title': ('django.db.models.fields.CharField', [],
 
54
                {'unique': 'True', 'max_length': '100'})
 
55
        },
 
56
        'oops.dboopsrootdirectory': {
 
57
            'Meta': {'object_name': 'DBOopsRootDirectory'},
 
58
            'id': ('django.db.models.fields.AutoField', [],
 
59
                {'primary_key': 'True'}),
 
60
            'last_date': ('django.db.models.fields.DateField', [],
 
61
                {'null': 'True'}),
 
62
            'last_oops': ('django.db.models.fields.CharField', [],
 
63
                {'max_length': '200', 'null': 'True'}),
 
64
            'root_dir': ('django.db.models.fields.CharField', [],
 
65
                {'unique': 'True', 'max_length': '200'})
 
66
        },
 
67
        'oops.infestation': {
 
68
            'Meta': {'unique_together':
 
69
                "(('exception_type', 'exception_value'),)",
 
70
                'object_name': 'Infestation'},
 
71
            'bug': ('django.db.models.fields.PositiveIntegerField', [],
 
72
                {'null': 'True'}),
 
73
            'exception_type': ('django.db.models.fields.CharField', [],
 
74
                {'max_length': '100'}),
 
75
            'exception_value': ('django.db.models.fields.CharField', [],
 
76
                {'max_length': '1000'}),
 
77
            'id': ('django.db.models.fields.AutoField', [],
 
78
                {'primary_key': 'True'}),
 
79
        },
 
80
        'oops.oops': {
 
81
            'Meta': {'object_name': 'Oops'},
 
82
            'appinstance': ('django.db.models.fields.related.ForeignKey', [],
 
83
                {'to': "orm['oops.AppInstance']"}),
 
84
            'classification': ('django.db.models.fields.related.ForeignKey', [],
 
85
                {'to': "orm['oops.Classification']", 'null': 'True'}),
 
86
            'date': ('django.db.models.fields.DateTimeField', [],
 
87
                {'db_index': 'True'}),
 
88
            'duration': ('django.db.models.fields.FloatField', [],
 
89
                {'null': 'True'}),
 
90
            'http_method': ('django.db.models.fields.CharField', [],
 
91
                {'max_length': '10', 'null': 'True'}),
 
92
            'id': ('django.db.models.fields.AutoField', [],
 
93
                {'primary_key': 'True'}),
 
94
            'informational': ('django.db.models.fields.NullBooleanField', [],
 
95
                {'null': 'True'}),
 
96
            'is_bot': ('django.db.models.fields.NullBooleanField', [],
 
97
                {'null': 'True', 'db_index': 'True'}),
 
98
            'is_local_referrer': ('django.db.models.fields.NullBooleanField', [],
 
99
                {'null': 'True', 'db_index': 'True'}),
 
100
            'most_expensive_statement': ('django.db.models.fields.CharField', [],
 
101
                {'max_length': '200', 'null': 'True', 'db_index': 'True'}),
 
102
            'oopsid': ('django.db.models.fields.CharField', [],
 
103
                {'unique': 'True', 'max_length': '200'}),
 
104
            'oopsinfestation': ('django.db.models.fields.related.ForeignKey', [],
 
105
                {'to': "orm['oops.Infestation']"}),
 
106
            'pageid': ('django.db.models.fields.CharField', [],
 
107
                {'max_length': '500'}),
 
108
            'pathname': ('django.db.models.fields.CharField', [],
 
109
                {'unique': 'True', 'max_length': '200'}),
 
110
            'prefix': ('django.db.models.fields.related.ForeignKey', [],
 
111
                {'to': "orm['oops.Prefix']"}),
 
112
            'referrer': ('django.db.models.fields.URLField', [],
 
113
                {'max_length': '500', 'null': 'True'}),
 
114
            'statements_count': ('django.db.models.fields.PositiveIntegerField', [],
 
115
                {}),
 
116
            'time_is_estimate': ('django.db.models.fields.NullBooleanField', [],
 
117
                {'null': 'True'}),
 
118
            'total_time': ('django.db.models.fields.PositiveIntegerField', [],
 
119
                {}),
 
120
            'url': ('django.db.models.fields.URLField', [],
 
121
                {'max_length': '500', 'null': 'True', 'db_index': 'True'}),
 
122
            'user_agent': ('django.db.models.fields.CharField', [],
 
123
                {'max_length': '200', 'null': 'True'})
 
124
        },
 
125
        'oops.prefix': {
 
126
            'Meta': {'object_name': 'Prefix'},
 
127
            'appinstance': ('django.db.models.fields.related.ForeignKey', [],
 
128
                {'to': "orm['oops.AppInstance']"}),
 
129
            'id': ('django.db.models.fields.AutoField', [],
 
130
                {'primary_key': 'True'}),
 
131
            'value': ('django.db.models.fields.CharField', [],
 
132
                {'unique': 'True', 'max_length': '20'})
 
133
        },
 
134
        'oops.project': {
 
135
            'Meta': {'object_name': 'Project'},
 
136
            'id': ('django.db.models.fields.AutoField', [],
 
137
                {'primary_key': 'True'}),
 
138
            'title': ('django.db.models.fields.CharField', [],
 
139
                {'unique': 'True', 'max_length': '200'})
 
140
        },
 
141
    }
 
142
 
 
143
    complete_apps = ['oops']