Skip to content

Commit

Permalink
Redo migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Dec 5, 2023
1 parent f03045e commit 1bc58e6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.7 on 2023-12-05 19:12
# Generated by Django 4.2.7 on 2023-12-05 19:22

import django.contrib.postgres.indexes
from django.db import migrations, models
Expand All @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="category",
name="plugin_data",
field=models.JSONField(blank=True, default=dict, null=True),
field=models.JSONField(default=dict),
),
migrations.AddIndex(
model_name="category",
Expand Down
26 changes: 1 addition & 25 deletions misago/plugins/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,8 @@


class PluginDataModel(models.Model):
plugin_data = models.JSONField(default=dict, blank=True, null=True)
plugin_data = models.JSONField(default=dict)

class Meta:
abstract = True
indexes = [GinIndex(fields=["plugin_data"])]

def plugin_data_in(self, key: str) -> bool:
if self.plugin_data is None:
return False

return key in self.plugin_data

def plugin_data_get(self, key: str, default=None) -> Any:
if self.plugin_data is None:
return default

return self.plugin_data.get(key, default)

def plugin_data_set(self, key: str, value: Any):
if self.plugin_data is None:
self.plugin_data = {}

self.plugin_data[key] = value

def plugin_data_update(self, value: dict):
if self.plugin_data is None:
self.plugin_data = {}

self.plugin_data.update(value)
71 changes: 71 additions & 0 deletions misago/threads/migrations/0014_plugin_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by Django 4.2.7 on 2023-12-05 19:22

import django.contrib.postgres.indexes
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
(
"misago_threads",
"0013_rename_pollvote_poll_voter_name_misago_thre_poll_id_c3e8fe_idx_and_more",
),
]

operations = [
migrations.AddField(
model_name="attachment",
name="plugin_data",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="attachmenttype",
name="plugin_data",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="poll",
name="plugin_data",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="post",
name="plugin_data",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="thread",
name="plugin_data",
field=models.JSONField(default=dict),
),
migrations.AddIndex(
model_name="attachment",
index=django.contrib.postgres.indexes.GinIndex(
fields=["plugin_data"], name="misago_thre_plugin__46d25a_gin"
),
),
migrations.AddIndex(
model_name="attachmenttype",
index=django.contrib.postgres.indexes.GinIndex(
fields=["plugin_data"], name="misago_thre_plugin__236db5_gin"
),
),
migrations.AddIndex(
model_name="poll",
index=django.contrib.postgres.indexes.GinIndex(
fields=["plugin_data"], name="misago_thre_plugin__5e1be7_gin"
),
),
migrations.AddIndex(
model_name="post",
index=django.contrib.postgres.indexes.GinIndex(
fields=["plugin_data"], name="misago_thre_plugin__91da06_gin"
),
),
migrations.AddIndex(
model_name="thread",
index=django.contrib.postgres.indexes.GinIndex(
fields=["plugin_data"], name="misago_thre_plugin__e6e836_gin"
),
),
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.7 on 2023-12-05 19:12
# Generated by Django 4.2.7 on 2023-12-05 19:22

import django.contrib.postgres.indexes
from django.db import migrations, models
Expand All @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="user",
name="plugin_data",
field=models.JSONField(blank=True, default=dict, null=True),
field=models.JSONField(default=dict),
),
migrations.AddIndex(
model_name="user",
Expand Down

0 comments on commit 1bc58e6

Please sign in to comment.