Browse Source

Squash migrations

David Burke 4 years ago
parent
commit
fa68e933ad

+ 45 - 14
alerts/migrations/0001_initial.py

@@ -9,29 +9,60 @@ class Migration(migrations.Migration):
     initial = True
 
     dependencies = [
-        ('projects', '0001_initial'),
-        ('issues', '0002_auto_20200306_1546'),
+        ("projects", "0001_initial"),
+        ("issues", "0001_squashed_0004_auto_20200612_0027"),
     ]
 
     operations = [
         migrations.CreateModel(
-            name='ProjectAlert',
+            name="ProjectAlert",
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('timespan_minutes', models.PositiveSmallIntegerField(blank=True, null=True)),
-                ('quantity', models.PositiveSmallIntegerField(blank=True, null=True)),
-                ('created', models.DateTimeField(auto_now_add=True)),
-                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project')),
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                (
+                    "timespan_minutes",
+                    models.PositiveSmallIntegerField(blank=True, null=True),
+                ),
+                ("quantity", models.PositiveSmallIntegerField(blank=True, null=True)),
+                ("created", models.DateTimeField(auto_now_add=True)),
+                (
+                    "project",
+                    models.ForeignKey(
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="projects.Project",
+                    ),
+                ),
             ],
         ),
         migrations.CreateModel(
-            name='Notification',
+            name="Notification",
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('created', models.DateField(auto_now_add=True)),
-                ('is_sent', models.BooleanField(default=False)),
-                ('issues', models.ManyToManyField(to='issues.Issue')),
-                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project')),
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("created", models.DateField(auto_now_add=True)),
+                ("is_sent", models.BooleanField(default=False)),
+                ("issues", models.ManyToManyField(to="issues.Issue")),
+                (
+                    "project",
+                    models.ForeignKey(
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="projects.Project",
+                    ),
+                ),
             ],
         ),
     ]

+ 140 - 0
events/migrations/0001_squashed_0003_auto_20210116_2110.py

@@ -0,0 +1,140 @@
+# Generated by Django 3.1.5 on 2021-01-17 17:07
+
+import django.contrib.postgres.fields.hstore
+import django.contrib.postgres.operations
+from django.db import migrations, models
+import django.db.models.deletion
+import uuid
+
+
+class Migration(migrations.Migration):
+
+    replaces = [
+        ("events", "0001_initial"),
+        ("events", "0002_auto_20201229_1643"),
+        ("events", "0003_auto_20210116_2110"),
+    ]
+
+    initial = True
+
+    dependencies = [
+        ("issues", "0009_auto_20201229_1622"),
+        ("releases", "0002_auto_20201227_1518"),
+    ]
+
+    operations = [
+        migrations.SeparateDatabaseAndState(
+            state_operations=[
+                migrations.CreateModel(
+                    name="Event",
+                    fields=[
+                        (
+                            "event_id",
+                            models.UUIDField(
+                                default=uuid.uuid4,
+                                editable=False,
+                                primary_key=True,
+                                serialize=False,
+                            ),
+                        ),
+                        (
+                            "timestamp",
+                            models.DateTimeField(
+                                blank=True,
+                                help_text="Date created as claimed by client it came from",
+                                null=True,
+                            ),
+                        ),
+                        (
+                            "created",
+                            models.DateTimeField(auto_now_add=True, db_index=True),
+                        ),
+                        ("data", models.JSONField()),
+                        (
+                            "issue",
+                            models.ForeignKey(
+                                help_text="Sentry calls this a group",
+                                on_delete=django.db.models.deletion.CASCADE,
+                                to="issues.issue",
+                            ),
+                        ),
+                        (
+                            "release",
+                            models.ForeignKey(
+                                blank=True,
+                                null=True,
+                                on_delete=django.db.models.deletion.SET_NULL,
+                                to="releases.release",
+                            ),
+                        ),
+                        (
+                            "tags",
+                            models.ManyToManyField(blank=True, to="events.EventTag"),
+                        ),
+                    ],
+                    options={"ordering": ["-created"],},
+                ),
+                migrations.CreateModel(
+                    name="EventTagKey",
+                    fields=[
+                        (
+                            "id",
+                            models.AutoField(
+                                auto_created=True,
+                                primary_key=True,
+                                serialize=False,
+                                verbose_name="ID",
+                            ),
+                        ),
+                        ("key", models.CharField(max_length=255, unique=True)),
+                    ],
+                ),
+                migrations.CreateModel(
+                    name="EventTag",
+                    fields=[
+                        (
+                            "id",
+                            models.AutoField(
+                                auto_created=True,
+                                primary_key=True,
+                                serialize=False,
+                                verbose_name="ID",
+                            ),
+                        ),
+                        ("value", models.CharField(max_length=225)),
+                        (
+                            "key",
+                            models.ForeignKey(
+                                on_delete=django.db.models.deletion.CASCADE,
+                                to="events.eventtagkey",
+                            ),
+                        ),
+                    ],
+                    options={"unique_together": {("key", "value")},},
+                ),
+            ],
+        ),
+        migrations.RunSQL(
+            sql="\nDROP TRIGGER IF EXISTS event_issue_update on events_event;\nDROP FUNCTION IF EXISTS update_issue;\n\nCREATE FUNCTION update_issue() RETURNS trigger AS $$\nDECLARE event_count INT;\nDECLARE events_search_vector tsvector;\nBEGIN\n\nevent_count := (SELECT count(*) from events_event where events_event.issue_id = new.issue_id);\n\nUPDATE issues_issue\nSET last_seen = new.created, count = event_count\nWHERE issues_issue.id = new.issue_id;\n\nIF event_count <= 100 THEN\n    BEGIN\n        events_search_vector := (\n            SELECT strip(jsonb_to_tsvector('english', jsonb_agg(events_event.data), '[\"string\"]'))\n            FROM events_event\n            WHERE events_event.issue_id = new.issue_id\n        );\n\n        UPDATE issues_issue\n        SET search_vector = events_search_vector \n        where issues_issue.id = new.issue_id;\n\n        EXCEPTION WHEN program_limit_exceeded THEN\n    END;\nEND IF;\n\nRETURN new;\nEND\n$$ LANGUAGE plpgsql;;\n\n\nCREATE TRIGGER event_issue_update AFTER INSERT OR UPDATE\nON events_event FOR EACH ROW EXECUTE PROCEDURE\nupdate_issue();\n",
+            reverse_sql="DROP TRIGGER IF EXISTS event_issue_update on issues_event; DROP FUNCTION IF EXISTS update_issue;",
+        ),
+        migrations.AlterField(
+            model_name="event",
+            name="issue",
+            field=models.ForeignKey(
+                help_text="Sentry calls this a group",
+                null=True,
+                on_delete=django.db.models.deletion.CASCADE,
+                to="issues.issue",
+            ),
+        ),
+        migrations.RemoveField(model_name="event", name="tags",),
+        django.contrib.postgres.operations.HStoreExtension(),
+        migrations.AddField(
+            model_name="event",
+            name="tags",
+            field=django.contrib.postgres.fields.hstore.HStoreField(default=dict),
+        ),
+        migrations.DeleteModel(name="EventTag",),
+        migrations.DeleteModel(name="EventTagKey",),
+    ]

+ 0 - 55
issues/migrations/0001_initial.py

@@ -1,55 +0,0 @@
-# Generated by Django 3.0.3 on 2020-02-28 17:52
-
-import django.contrib.postgres.fields.jsonb
-from django.db import migrations, models
-import django.db.models.deletion
-import uuid
-
-
-class Migration(migrations.Migration):
-
-    initial = True
-
-    dependencies = [
-        ('projects', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.CreateModel(
-            name='EventTag',
-            fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('key', models.CharField(max_length=255)),
-                ('value', models.CharField(max_length=225)),
-            ],
-        ),
-        migrations.CreateModel(
-            name='Issue',
-            fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('created', models.DateTimeField(auto_now_add=True, db_index=True)),
-                ('culprit', models.CharField(blank=True, max_length=1024, null=True)),
-                ('has_seen', models.BooleanField(default=False)),
-                ('is_public', models.BooleanField(default=False)),
-                ('level', models.PositiveSmallIntegerField(choices=[(0, 'sample'), (1, 'debug'), (2, 'info'), (3, 'warning'), (4, 'error'), (5, 'fatal')], default=0)),
-                ('metadata', django.contrib.postgres.fields.jsonb.JSONField()),
-                ('title', models.CharField(max_length=255)),
-                ('type', models.PositiveSmallIntegerField(choices=[(0, 'default'), (1, 'error'), (2, 'csp')], default=0)),
-                ('status', models.PositiveSmallIntegerField(choices=[(0, 'unresolved'), (1, 'resolved'), (2, 'ignored')], default=0)),
-                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project')),
-            ],
-        ),
-        migrations.CreateModel(
-            name='Event',
-            fields=[
-                ('event_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
-                ('timestamp', models.DateTimeField(blank=True, help_text='Date created as claimed by client it came from', null=True)),
-                ('created', models.DateTimeField(auto_now_add=True, db_index=True)),
-                ('data', django.contrib.postgres.fields.jsonb.JSONField()),
-                ('issue', models.ForeignKey(help_text='Sentry calls this a group', on_delete=django.db.models.deletion.CASCADE, to='issues.Issue')),
-            ],
-            options={
-                'ordering': ['-created'],
-            },
-        ),
-    ]

+ 0 - 8
issues/migrations/0001_squashed_0004_auto_20200612_0027.py

@@ -11,14 +11,6 @@ from .sql.triggers import UPDATE_ISSUE_TRIGGER
 
 
 class Migration(migrations.Migration):
-
-    replaces = [
-        ("issues", "0001_initial"),
-        ("issues", "0002_auto_20200306_1546"),
-        ("issues", "0003_event_search_vector"),
-        ("issues", "0004_auto_20200612_0027"),
-    ]
-
     initial = True
 
     dependencies = [

+ 248 - 0
issues/migrations/0001_squashed_0010_auto_20210117_1543.py

@@ -0,0 +1,248 @@
+# Generated by Django 3.1.5 on 2021-01-17 17:02
+
+import django.contrib.postgres.fields.jsonb
+import django.contrib.postgres.indexes
+import django.contrib.postgres.search
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+import uuid
+
+
+class Migration(migrations.Migration):
+
+    replaces = [
+        ("issues", "0001_squashed_0004_auto_20200612_0027"),
+        ("issues", "0002_auto_20200714_1333"),
+        ("issues", "0003_auto_20200731_1531"),
+        ("issues", "0004_auto_20200804_0053"),
+        ("issues", "0005_auto_20200805_0107"),
+        ("issues", "0006_auto_20201027_0018"),
+        ("issues", "0007_auto_20201113_1843"),
+        ("issues", "0008_event_release"),
+        ("issues", "0009_auto_20201229_1622"),
+        ("issues", "0010_auto_20210117_1543"),
+    ]
+
+    initial = True
+
+    dependencies = [
+        ("releases", "0002_auto_20201227_1518"),
+        ("projects", "0001_initial"),
+        ("projects", "0003_projectcounter"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="EventTag",
+            fields=[
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("key", models.CharField(max_length=255)),
+                ("value", models.CharField(max_length=225)),
+            ],
+        ),
+        migrations.CreateModel(
+            name="Issue",
+            fields=[
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
+                ("culprit", models.CharField(blank=True, max_length=1024, null=True)),
+                ("has_seen", models.BooleanField(default=False)),
+                ("is_public", models.BooleanField(default=False)),
+                (
+                    "level",
+                    models.PositiveSmallIntegerField(
+                        choices=[
+                            (0, "sample"),
+                            (1, "debug"),
+                            (2, "info"),
+                            (3, "warning"),
+                            (4, "error"),
+                            (5, "fatal"),
+                        ],
+                        default=0,
+                    ),
+                ),
+                ("metadata", django.contrib.postgres.fields.jsonb.JSONField()),
+                ("title", models.CharField(max_length=255)),
+                (
+                    "type",
+                    models.PositiveSmallIntegerField(
+                        choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
+                    ),
+                ),
+                (
+                    "status",
+                    models.PositiveSmallIntegerField(
+                        choices=[(0, "unresolved"), (1, "resolved"), (2, "ignored")],
+                        default=0,
+                    ),
+                ),
+                (
+                    "project",
+                    models.ForeignKey(
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="projects.project",
+                    ),
+                ),
+                ("count", models.PositiveIntegerField(default=1, editable=False)),
+                (
+                    "last_seen",
+                    models.DateTimeField(
+                        auto_now_add=True, default=django.utils.timezone.now
+                    ),
+                ),
+                (
+                    "search_vector",
+                    django.contrib.postgres.search.SearchVectorField(
+                        editable=False, null=True
+                    ),
+                ),
+            ],
+            options={"unique_together": {("title", "culprit", "project", "type")},},
+        ),
+        migrations.CreateModel(
+            name="Event",
+            fields=[
+                (
+                    "event_id",
+                    models.UUIDField(
+                        default=uuid.uuid4,
+                        editable=False,
+                        primary_key=True,
+                        serialize=False,
+                    ),
+                ),
+                (
+                    "timestamp",
+                    models.DateTimeField(
+                        blank=True,
+                        help_text="Date created as claimed by client it came from",
+                        null=True,
+                    ),
+                ),
+                ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
+                ("data", django.contrib.postgres.fields.jsonb.JSONField()),
+                (
+                    "issue",
+                    models.ForeignKey(
+                        help_text="Sentry calls this a group",
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="issues.issue",
+                    ),
+                ),
+            ],
+            options={"ordering": ["-created"],},
+        ),
+        migrations.AddIndex(
+            model_name="issue",
+            index=django.contrib.postgres.indexes.GinIndex(
+                fields=["search_vector"], name="search_vector_idx"
+            ),
+        ),
+        migrations.AddField(
+            model_name="issue",
+            name="short_id",
+            field=models.PositiveIntegerField(null=True),
+        ),
+        migrations.AlterUniqueTogether(
+            name="issue",
+            unique_together={
+                ("title", "culprit", "project", "type"),
+                ("project", "short_id"),
+            },
+        ),
+        migrations.RunSQL(
+            sql="\nDROP TRIGGER IF EXISTS increment_project_counter on issues_issue;\n\nCREATE OR REPLACE FUNCTION increment_project_counter() RETURNS trigger AS $$\nDECLARE\n    counter_value int;\nBEGIN\n    INSERT INTO projects_projectcounter (value, project_id)\n    VALUES (0, NEW.project_id)\n    ON CONFLICT (project_id) DO UPDATE SET value = projects_projectcounter.value + 1\n    RETURNING value into counter_value;\n    NEW.short_id=counter_value;\n    RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;;\n\nCREATE TRIGGER increment_project_counter BEFORE INSERT\nON issues_issue FOR EACH ROW EXECUTE PROCEDURE\nincrement_project_counter();\n",
+            reverse_sql="DROP TRIGGER IF EXISTS increment_project_counter on issues_issue; DROP FUNCTION IF EXISTS increment_project_counter;",
+        ),
+        migrations.CreateModel(
+            name="EventTagKey",
+            fields=[
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("key", models.CharField(max_length=255, unique=True)),
+            ],
+        ),
+        migrations.AddField(
+            model_name="event",
+            name="tags",
+            field=models.ManyToManyField(blank=True, to="issues.EventTag"),
+        ),
+        migrations.AlterField(
+            model_name="eventtag",
+            name="key",
+            field=models.ForeignKey(
+                on_delete=django.db.models.deletion.CASCADE, to="issues.eventtagkey"
+            ),
+        ),
+        migrations.AlterUniqueTogether(
+            name="eventtag", unique_together={("key", "value")},
+        ),
+        migrations.AlterField(
+            model_name="event", name="data", field=models.JSONField(),
+        ),
+        migrations.AlterField(
+            model_name="issue", name="metadata", field=models.JSONField(),
+        ),
+        migrations.AlterField(
+            model_name="issue",
+            name="last_seen",
+            field=models.DateTimeField(auto_now_add=True, db_index=True),
+        ),
+        migrations.AddField(
+            model_name="event",
+            name="release",
+            field=models.ForeignKey(
+                blank=True,
+                null=True,
+                on_delete=django.db.models.deletion.SET_NULL,
+                to="releases.release",
+            ),
+        ),
+        migrations.SeparateDatabaseAndState(
+            database_operations=[
+                migrations.AlterModelTable(name="Event", table="events_event",),
+                migrations.AlterModelTable(
+                    name="EventTagKey", table="events_eventtagkey",
+                ),
+                migrations.AlterModelTable(name="EventTag", table="events_eventtag",),
+            ],
+            state_operations=[
+                migrations.DeleteModel(name="Event",),
+                migrations.DeleteModel(name="EventTagKey",),
+                migrations.DeleteModel(name="EventTag",),
+            ],
+        ),
+        migrations.AlterField(
+            model_name="issue",
+            name="type",
+            field=models.PositiveSmallIntegerField(
+                choices=[(0, "default"), (1, "error"), (2, "csp"), (3, "transaction")],
+                default=0,
+            ),
+        ),
+    ]

+ 86 - 0
organizations_ext/migrations/0001_squashed_0009_organization_scrub_ip_addresses.py

@@ -0,0 +1,86 @@
+# Generated by Django 3.1.5 on 2021-01-17 17:09
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+import organizations.base
+import organizations.fields
+
+
+class Migration(migrations.Migration):
+
+    replaces = [('organizations_ext', '0001_initial'), ('organizations_ext', '0002_organization_is_accepting_events'), ('organizations_ext', '0003_auto_20200516_1724'), ('organizations_ext', '0004_organization_throttling_cycle_anchor'), ('organizations_ext', '0005_remove_organization_throttling_cycle_anchor'), ('organizations_ext', '0006_organization_open_membership'), ('organizations_ext', '0007_auto_20200619_1459'), ('organizations_ext', '0008_remove_organizationuser_pending'), ('organizations_ext', '0009_organization_scrub_ip_addresses')]
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Organization',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(help_text='The name of the organization', max_length=200)),
+                ('is_active', models.BooleanField(default=True)),
+                ('created', organizations.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
+                ('modified', organizations.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
+                ('slug', organizations.fields.SlugField(blank=True, editable=False, help_text='The name in all lowercase, suitable for URL identification', max_length=200, populate_from='name', unique=True)),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=(organizations.base.UnicodeMixin, models.Model),
+        ),
+        migrations.CreateModel(
+            name='OrganizationUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('created', organizations.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
+                ('modified', organizations.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
+                ('role', models.PositiveSmallIntegerField(choices=[(0, 'Member'), (1, 'Admin'), (2, 'Manager'), (3, 'Owner')])),
+                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organization_users', to='organizations_ext.organization')),
+                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='organizations_ext_organizationuser', to=settings.AUTH_USER_MODEL)),
+                ('email', models.EmailField(blank=True, help_text='Email for pending invite', max_length=254, null=True)),
+            ],
+            options={
+                'abstract': False,
+                'unique_together': {('email', 'organization'), ('user', 'organization')},
+            },
+            bases=(organizations.base.UnicodeMixin, models.Model),
+        ),
+        migrations.CreateModel(
+            name='OrganizationOwner',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('organization', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='owner', to='organizations_ext.organization')),
+                ('organization_user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='organizations_ext.organizationuser')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=(organizations.base.UnicodeMixin, models.Model),
+        ),
+        migrations.AddField(
+            model_name='organization',
+            name='users',
+            field=models.ManyToManyField(related_name='organizations_ext_organization', through='organizations_ext.OrganizationUser', to=settings.AUTH_USER_MODEL),
+        ),
+        migrations.AddField(
+            model_name='organization',
+            name='is_accepting_events',
+            field=models.BooleanField(default=True, help_text='Used for throttling at org level'),
+        ),
+        migrations.AddField(
+            model_name='organization',
+            name='open_membership',
+            field=models.BooleanField(default=True, help_text='Allow any organization member to join any team'),
+        ),
+        migrations.AddField(
+            model_name='organization',
+            name='scrub_ip_addresses',
+            field=models.BooleanField(default=True, help_text='Default for whether projects should script IP Addresses'),
+        ),
+    ]