Skip to content

Commit eb2eaf9

Browse files
author
Nicolas Cornu
committed
Fix column branch_id for Postgresql
1 parent dfb560a commit eb2eaf9

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

codespeed/migrations/0006_auto__chg_field_revision_branch.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
class Migration(SchemaMigration):
88

99
def forwards(self, orm):
10-
11-
# Renaming column for 'Revision.branch' to match new field type.
12-
db.rename_column('codespeed_revision', 'branch', 'branch_id')
13-
# Changing field 'Revision.branch'
14-
db.alter_column('codespeed_revision', 'branch_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['codespeed.Branch']))
10+
11+
# Adding field 'Revision.branch_id'
12+
db.add_column('codespeed_revision', 'branch', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['codespeed.Branch']))
13+
# Removing unique constraint on 'Revision', fields ['commitid', 'project', branch']
14+
db.delete_unique('codespeed_revision', ['commitid', 'project_id', 'branch'])
15+
# Delete field 'Revision.branch'
16+
db.delete_column('codespeed_revision', 'branch')
17+
# Adding unique constraint on 'Revision', fields ['commitid', 'project_id', 'branch_id']
18+
db.create_unique('codespeed_revision', ['commitid', 'project_id', 'branch_id'])
19+
1520

1621
# Adding index on 'Revision', fields ['branch']
1722
# NOTE: commented out because it can cause an
@@ -20,7 +25,7 @@ def forwards(self, orm):
2025

2126

2227
def backwards(self, orm):
23-
28+
2429
# Removing index on 'Revision', fields ['branch']
2530
db.delete_index('codespeed_revision', ['branch_id'])
2631

0 commit comments

Comments
 (0)