-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use indexes instead of index_together in models
index_together is deprecated and will be removed in django future
- Loading branch information
Showing
3 changed files
with
196 additions
and
1 deletion.
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
172 changes: 172 additions & 0 deletions
172
dalec_prime/migrations/0001_squashed_0005_auto_20231017_1208.py
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,172 @@ | ||
# Generated by Django 4.2.5 on 2023-10-17 10:26 | ||
|
||
import django.core.serializers.json | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
try: | ||
# Django imports | ||
from django.db.models import JSONField # type: ignore | ||
except ImportError: | ||
from django_jsonfield_backport.models import JSONField # type: ignore | ||
|
||
|
||
class Migration(migrations.Migration): | ||
replaces = [ | ||
("dalec_prime", "0001_initial"), | ||
("dalec_prime", "0002_auto_20211109_1546"), | ||
("dalec_prime", "0003_auto_20211109_1615"), | ||
("dalec_prime", "0004_alter_content_id_alter_fetchhistory_id"), | ||
("dalec_prime", "0005_auto_20231017_1208"), | ||
] | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("contenttypes", "0002_remove_content_type_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="FetchHistory", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
"last_fetch_dt", | ||
models.DateTimeField(auto_now=True, verbose_name="last fetch datetime"), | ||
), | ||
("app", models.CharField(max_length=50, verbose_name="dalec app")), | ||
( | ||
"content_type", | ||
models.CharField( | ||
blank=True, max_length=50, null=True, verbose_name="content type" | ||
), | ||
), | ||
( | ||
"channel", | ||
models.CharField(blank=True, max_length=50, null=True, verbose_name="channel"), | ||
), | ||
( | ||
"channel_object", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="channel app object id" | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Content fetch history line", | ||
"verbose_name_plural": "Content fetch history lines", | ||
"ordering": ("-last_fetch_dt",), | ||
"get_latest_by": "last_fetch_dt", | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="Content", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
"last_update_dt", | ||
models.DateTimeField( | ||
db_index=True, verbose_name="last update datetime (on external source)" | ||
), | ||
), | ||
( | ||
"creation_dt", | ||
models.DateTimeField( | ||
db_index=True, verbose_name="created datetime (on external source)" | ||
), | ||
), | ||
("app", models.CharField(max_length=50, verbose_name="dalec app")), | ||
( | ||
"content_type", | ||
models.CharField( | ||
blank=True, max_length=50, null=True, verbose_name="content type" | ||
), | ||
), | ||
( | ||
"channel", | ||
models.CharField(blank=True, max_length=50, null=True, verbose_name="channel"), | ||
), | ||
( | ||
"channel_object", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="channel app object id" | ||
), | ||
), | ||
( | ||
"dj_channel_id", | ||
models.PositiveIntegerField( | ||
blank=True, | ||
help_text="The django's model's instance which is concerned.(eg. could be an instance of model `Project` for app=gitlab, content_type=issue, channel=project)", | ||
null=True, | ||
verbose_name="related object", | ||
), | ||
), | ||
( | ||
"dj_content_id", | ||
models.PositiveIntegerField( | ||
blank=True, | ||
help_text="The django's model's instance which is concerned (eg. could be an instance of model `Issue` for dalec-gitlab)", | ||
null=True, | ||
verbose_name="content", | ||
), | ||
), | ||
( | ||
"content_id", | ||
models.CharField( | ||
help_text="ID of the content inside the external app.", | ||
max_length=255, | ||
verbose_name="app's content id", | ||
), | ||
), | ||
( | ||
"content_data", | ||
JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder), | ||
), | ||
( | ||
"dj_channel_content_type", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="+", | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
( | ||
"dj_content_content_type", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="+", | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Content", | ||
"verbose_name_plural": "Contents", | ||
"ordering": ("-last_update_dt",), | ||
"get_latest_by": "last_update_dt", | ||
"abstract": False, | ||
"indexes": [ | ||
models.Index( | ||
fields=["app", "content_type", "channel", "channel_object"], | ||
name="content", | ||
) | ||
], | ||
}, | ||
), | ||
] |
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,23 @@ | ||
# Generated by Django 3.2.21 on 2023-10-17 10:08 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("dalec_prime", "0004_alter_content_id_alter_fetchhistory_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterIndexTogether( | ||
name="content", | ||
index_together=set(), | ||
), | ||
migrations.AddIndex( | ||
model_name="content", | ||
index=models.Index( | ||
fields=["app", "content_type", "channel", "channel_object"], | ||
name="content", | ||
), | ||
), | ||
] |