From a116f0d94221f72fa14d90ec77b9777efbfada65 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 14 Dec 2013 11:24:57 -0600 Subject: Add update query for extracting Flyspray bug number Signed-off-by: Dan McGee --- mirrors/migrations/0027_auto__add_field_mirror_bug.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mirrors/migrations/0027_auto__add_field_mirror_bug.py b/mirrors/migrations/0027_auto__add_field_mirror_bug.py index 5772733..f7304ba 100644 --- a/mirrors/migrations/0027_auto__add_field_mirror_bug.py +++ b/mirrors/migrations/0027_auto__add_field_mirror_bug.py @@ -9,6 +9,14 @@ class Migration(SchemaMigration): db.add_column(u'mirrors_mirror', 'bug', self.gf('django.db.models.fields.PositiveIntegerField')(null=True), keep_default=False) + # UPDATE mirrors_mirror m + # SET bug = ( + # SELECT extracted::int FROM ( + # SELECT id, substring(notes from 'FS#([\d]+)') AS extracted FROM mirrors_mirror + # ) a + # WHERE extracted IS NOT NULL AND a.id = m.id + # ) + # WHERE notes LIKE '%FS#%'; def backwards(self, orm): db.delete_column(u'mirrors_mirror', 'bug') -- cgit v1.2.3-24-g4f1b