Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ auth: 0008_alter_user_username_max_length
contenttypes: 0002_remove_content_type_name
jira_ac: 0001_initial
nodestore: 0001_initial
sentry: 0112_groupinboxmodel
sentry: 0113_add_repositoryprojectpathconfig
sessions: 0001_initial
sites: 0002_alter_domain_unique
social_auth: 0001_initial
57 changes: 57 additions & 0 deletions src/sentry/migrations/0113_add_repositoryprojectpathconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-10-15 17:38
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import sentry.db.models.fields.bounded
import sentry.db.models.fields.foreignkey


class Migration(migrations.Migration):
# This flag is used to mark that a migration shouldn't be automatically run in
# production. We set this to True for operations that we think are risky and want
# someone from ops to run manually and monitor.
# General advice is that if in doubt, mark your migration as `is_dangerous`.
# Some things you should always mark as dangerous:
# - Large data migrations. Typically we want these to be run manually by ops so that
# they can be monitored. Since data migrations will now hold a transaction open
# this is even more important.
# - Adding columns to highly active tables, even ones that are NULL.
is_dangerous = False

# This flag is used to decide whether to run this migration in a transaction or not.
# By default we prefer to run in a transaction, but for migrations where you want
# to `CREATE INDEX CONCURRENTLY` this needs to be set to False. Typically you'll
# want to create an index concurrently when adding one to an existing table.
atomic = True


dependencies = [
('sentry', '0112_groupinboxmodel'),
]

operations = [
migrations.CreateModel(
name='RepositoryProjectPathConfig',
fields=[
('id', sentry.db.models.fields.bounded.BoundedBigAutoField(primary_key=True, serialize=False)),
('date_updated', models.DateTimeField(default=django.utils.timezone.now)),
('date_added', models.DateTimeField(default=django.utils.timezone.now, null=True)),
('stack_root', models.TextField()),
('source_root', models.TextField()),
('default_branch', models.TextField(null=True)),
('organization_integration', sentry.db.models.fields.foreignkey.FlexibleForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sentry.OrganizationIntegration')),
('project', sentry.db.models.fields.foreignkey.FlexibleForeignKey(db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to='sentry.Project')),
('repository', sentry.db.models.fields.foreignkey.FlexibleForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sentry.Repository')),
],
options={
'db_table': 'sentry_repositoryprojectpathconfig',
},
),
migrations.AlterUniqueTogether(
name='repositoryprojectpathconfig',
unique_together=set([('project', 'stack_root')]),
),
]
16 changes: 16 additions & 0 deletions src/sentry/models/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ class Meta:
unique_together = (("organization_integration_id", "external_id"),)


class RepositoryProjectPathConfig(DefaultFieldsModel):
__core__ = False

repository = FlexibleForeignKey("sentry.Repository")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeredithAnya should we have db_constraint=False here as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably fine, I don't think repository is very high volume. Can't check at the moment :(

project = FlexibleForeignKey("sentry.Project", db_constraint=False)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wedamija I wasn't sure if I should have added db_index=False here if the unique constraint will also create an index.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can, it's probably fine either way. That's really just an optimisation, and this table probably won't be large enough or high volume enough for it to be important.

organization_integration = FlexibleForeignKey("sentry.OrganizationIntegration")
stack_root = models.TextField()
source_root = models.TextField()
default_branch = models.TextField(null=True)

class Meta:
app_label = "sentry"
db_table = "sentry_repositoryprojectpathconfig"
unique_together = (("project", "stack_root"),)


class OrganizationIntegration(DefaultFieldsModel):
__core__ = False

Expand Down