forked from TracyWebTech/colab
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.db import connections | ||
from south.v2 import DataMigration | ||
|
||
class Migration(DataMigration): | ||
|
||
def forwards(self, orm): | ||
# Selecting trac database | ||
connection = connections['trac'] | ||
|
||
cursor = connection.cursor() | ||
cursor.execute(''' | ||
CREATE OR REPLACE VIEW ticket_collab_count_view AS | ||
SELECT | ||
COALESCE (t1.author, t2.author) as author, | ||
(COALESCE(t1.count, 0) + COALESCE(t2.count, 0)) as count | ||
FROM | ||
(SELECT author, count(*) as count | ||
FROM ticket_change | ||
GROUP BY author | ||
ORDER BY author | ||
) AS t1 | ||
FULL OUTER JOIN | ||
(SELECT reporter as author, count(*) as count | ||
FROM ticket | ||
GROUP BY reporter | ||
ORDER BY reporter | ||
) AS t2 | ||
ON t1.author = t2.author; | ||
CREATE OR REPLACE VIEW wiki_collab_count_view AS | ||
SELECT author, count(*) from wiki GROUP BY author; | ||
''') | ||
|
||
def backwards(self, orm): | ||
# Selecting trac database | ||
connection = connections['trac'] | ||
|
||
cursor = connection.cursor() | ||
cursor.execute(''' | ||
DROP VIEW ticket_collab_count_view; | ||
DROP VIEW wiki_collab_count_view; | ||
''') | ||
|
||
complete_apps = ['proxy'] | ||
symmetrical = True |