Skip to content

Commit a255e71

Browse files
author
Riccardo Busetti
authored
feat(sourcemaps): Implement new tables supporting debug ids (#44572)
1 parent 48207fc commit a255e71

File tree

4 files changed

+242
-1
lines changed

4 files changed

+242
-1
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ To resolve this, rebase against latest master and regenerate your migration. Thi
66
will then be regenerated, and you should be able to merge without conflicts.
77

88
nodestore: 0002_nodestore_no_dictfield
9-
sentry: 0362_break_project_integration_fk
9+
sentry: 0363_debug_id_artifact_bundle
1010
social_auth: 0001_initial
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Generated by Django 2.2.28 on 2023-02-27 10:53
2+
3+
import django.db.models.deletion
4+
import django.utils.timezone
5+
from django.db import migrations, models
6+
7+
import sentry.db.models.fields.bounded
8+
import sentry.db.models.fields.foreignkey
9+
from sentry.new_migrations.migrations import CheckedMigration
10+
11+
12+
class Migration(CheckedMigration):
13+
# This flag is used to mark that a migration shouldn't be automatically run in production. For
14+
# the most part, this should only be used for operations where it's safe to run the migration
15+
# after your code has deployed. So this should not be used for most operations that alter the
16+
# schema of a table.
17+
# Here are some things that make sense to mark as dangerous:
18+
# - Large data migrations. Typically we want these to be run manually by ops so that they can
19+
# be monitored and not block the deploy for a long period of time while they run.
20+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
21+
# have ops run this and not block the deploy. Note that while adding an index is a schema
22+
# change, it's completely safe to run the operation after the code has deployed.
23+
is_dangerous = False
24+
25+
dependencies = [
26+
("sentry", "0362_break_project_integration_fk"),
27+
]
28+
29+
operations = [
30+
migrations.CreateModel(
31+
name="ArtifactBundle",
32+
fields=[
33+
(
34+
"id",
35+
sentry.db.models.fields.bounded.BoundedBigAutoField(
36+
primary_key=True, serialize=False
37+
),
38+
),
39+
(
40+
"organization_id",
41+
sentry.db.models.fields.bounded.BoundedBigIntegerField(db_index=True),
42+
),
43+
("bundle_id", models.UUIDField(null=True)),
44+
("artifact_count", sentry.db.models.fields.bounded.BoundedPositiveIntegerField()),
45+
("date_added", models.DateTimeField(default=django.utils.timezone.now)),
46+
(
47+
"file",
48+
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
49+
on_delete=django.db.models.deletion.CASCADE, to="sentry.File"
50+
),
51+
),
52+
],
53+
options={
54+
"db_table": "sentry_artifactbundle",
55+
"unique_together": {("organization_id", "bundle_id")},
56+
},
57+
),
58+
migrations.CreateModel(
59+
name="ReleaseArtifactBundle",
60+
fields=[
61+
(
62+
"id",
63+
sentry.db.models.fields.bounded.BoundedBigAutoField(
64+
primary_key=True, serialize=False
65+
),
66+
),
67+
(
68+
"organization_id",
69+
sentry.db.models.fields.bounded.BoundedBigIntegerField(db_index=True),
70+
),
71+
("release_name", models.CharField(max_length=250)),
72+
("dist_id", sentry.db.models.fields.bounded.BoundedBigIntegerField(null=True)),
73+
("date_added", models.DateTimeField(default=django.utils.timezone.now)),
74+
(
75+
"artifact_bundle",
76+
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
77+
on_delete=django.db.models.deletion.CASCADE, to="sentry.ArtifactBundle"
78+
),
79+
),
80+
],
81+
options={
82+
"db_table": "sentry_releaseartifactbundle",
83+
"unique_together": {
84+
("organization_id", "release_name", "dist_id", "artifact_bundle")
85+
},
86+
},
87+
),
88+
migrations.CreateModel(
89+
name="ProjectArtifactBundle",
90+
fields=[
91+
(
92+
"id",
93+
sentry.db.models.fields.bounded.BoundedBigAutoField(
94+
primary_key=True, serialize=False
95+
),
96+
),
97+
(
98+
"organization_id",
99+
sentry.db.models.fields.bounded.BoundedBigIntegerField(db_index=True),
100+
),
101+
(
102+
"project_id",
103+
sentry.db.models.fields.bounded.BoundedBigIntegerField(db_index=True),
104+
),
105+
("date_added", models.DateTimeField(default=django.utils.timezone.now)),
106+
(
107+
"artifact_bundle",
108+
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
109+
on_delete=django.db.models.deletion.CASCADE, to="sentry.ArtifactBundle"
110+
),
111+
),
112+
],
113+
options={
114+
"db_table": "sentry_projectartifactbundle",
115+
"unique_together": {("project_id", "artifact_bundle")},
116+
},
117+
),
118+
migrations.CreateModel(
119+
name="DebugIdArtifactBundle",
120+
fields=[
121+
(
122+
"id",
123+
sentry.db.models.fields.bounded.BoundedBigAutoField(
124+
primary_key=True, serialize=False
125+
),
126+
),
127+
(
128+
"organization_id",
129+
sentry.db.models.fields.bounded.BoundedBigIntegerField(db_index=True),
130+
),
131+
("debug_id", models.UUIDField()),
132+
("source_file_type", models.IntegerField()),
133+
("date_added", models.DateTimeField(default=django.utils.timezone.now)),
134+
("date_last_accessed", models.DateTimeField(default=django.utils.timezone.now)),
135+
(
136+
"artifact_bundle",
137+
sentry.db.models.fields.foreignkey.FlexibleForeignKey(
138+
on_delete=django.db.models.deletion.CASCADE, to="sentry.ArtifactBundle"
139+
),
140+
),
141+
],
142+
options={
143+
"db_table": "sentry_debugidartifactbundle",
144+
"unique_together": {("debug_id", "artifact_bundle", "source_file_type")},
145+
},
146+
),
147+
]

src/sentry/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .apiscopes import * # NOQA
88
from .apitoken import * # NOQA
99
from .appconnectbuilds import * # NOQA
10+
from .artifactbundle import * # NOQA
1011
from .assistant import * # NOQA
1112
from .auditlogentry import * # NOQA
1213
from .authenticator import * # NOQA
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from enum import Enum
2+
3+
from django.db import models
4+
from django.utils import timezone
5+
6+
from sentry.db.models import (
7+
BoundedBigIntegerField,
8+
BoundedPositiveIntegerField,
9+
FlexibleForeignKey,
10+
Model,
11+
region_silo_only_model,
12+
)
13+
14+
15+
class SourceFileType(Enum):
16+
SOURCE = 1
17+
MINIFIED_SOURCE = 2
18+
SOURCE_MAP = 3
19+
INDEXED_RAM_BUNDLE = 4
20+
21+
@classmethod
22+
def choices(cls):
23+
return [(key.value, key.name) for key in cls]
24+
25+
26+
@region_silo_only_model
27+
class ArtifactBundle(Model):
28+
__include_in_export__ = False
29+
30+
organization_id = BoundedBigIntegerField(db_index=True)
31+
bundle_id = models.UUIDField(null=True)
32+
file = FlexibleForeignKey("sentry.File")
33+
artifact_count = BoundedPositiveIntegerField()
34+
date_added = models.DateTimeField(default=timezone.now)
35+
36+
class Meta:
37+
app_label = "sentry"
38+
db_table = "sentry_artifactbundle"
39+
40+
unique_together = (("organization_id", "bundle_id"),)
41+
42+
43+
@region_silo_only_model
44+
class ReleaseArtifactBundle(Model):
45+
__include_in_export__ = False
46+
47+
organization_id = BoundedBigIntegerField(db_index=True)
48+
release_name = models.CharField(max_length=250)
49+
dist_id = BoundedBigIntegerField(null=True)
50+
artifact_bundle = FlexibleForeignKey("sentry.ArtifactBundle")
51+
date_added = models.DateTimeField(default=timezone.now)
52+
53+
class Meta:
54+
app_label = "sentry"
55+
db_table = "sentry_releaseartifactbundle"
56+
57+
unique_together = (("organization_id", "release_name", "dist_id", "artifact_bundle"),)
58+
59+
60+
@region_silo_only_model
61+
class DebugIdArtifactBundle(Model):
62+
__include_in_export__ = False
63+
64+
organization_id = BoundedBigIntegerField(db_index=True)
65+
debug_id = models.UUIDField()
66+
artifact_bundle = FlexibleForeignKey("sentry.ArtifactBundle")
67+
source_file_type = models.IntegerField(choices=SourceFileType.choices())
68+
date_added = models.DateTimeField(default=timezone.now)
69+
date_last_accessed = models.DateTimeField(default=timezone.now)
70+
71+
class Meta:
72+
app_label = "sentry"
73+
db_table = "sentry_debugidartifactbundle"
74+
75+
# We can have the same debug_id pointing to different artifact_bundle(s) because the user might upload
76+
# the same artifacts twice, or they might have certain build files that don't change across builds.
77+
unique_together = (("debug_id", "artifact_bundle", "source_file_type"),)
78+
79+
80+
@region_silo_only_model
81+
class ProjectArtifactBundle(Model):
82+
__include_in_export__ = False
83+
84+
organization_id = BoundedBigIntegerField(db_index=True)
85+
project_id = BoundedBigIntegerField(db_index=True)
86+
artifact_bundle = FlexibleForeignKey("sentry.ArtifactBundle")
87+
date_added = models.DateTimeField(default=timezone.now)
88+
89+
class Meta:
90+
app_label = "sentry"
91+
db_table = "sentry_projectartifactbundle"
92+
93+
unique_together = (("project_id", "artifact_bundle"),)

0 commit comments

Comments
 (0)