~launchpad-pqm/python-oops-tools/trunk

« back to all changes in this revision

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