feat: add community contribution ranks
This commit is contained in:
47
apps/gamification/migrations/0001_initial.py
Normal file
47
apps/gamification/migrations/0001_initial.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# Generated by Django 5.2.5 on 2026-09-29 12:54
|
||||
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ScoringEpoch',
|
||||
fields=[
|
||||
('id', models.PositiveSmallIntegerField(default=1, editable=False, primary_key=True, serialize=False)),
|
||||
('started_at', models.DateTimeField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ContributionLedger',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('activity', models.CharField(choices=[('attendance', 'Event attendance'), ('post', 'Published post'), ('comment', 'Approved comment or reply'), ('like', 'Like given or received'), ('save', 'Save given or received')], max_length=20)),
|
||||
('source_type', models.CharField(max_length=32)),
|
||||
('source_id', models.CharField(max_length=80)),
|
||||
('effect_key', models.CharField(db_index=True, max_length=240)),
|
||||
('role', models.CharField(max_length=20)),
|
||||
('points', models.IntegerField()),
|
||||
('idempotency_key', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('reason', models.CharField(blank=True, max_length=120)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('reversal_of', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='reversals', to='gamification.contributionledger')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contribution_ledger_entries', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['created_at', 'id'],
|
||||
'indexes': [models.Index(fields=['user', 'activity'], name='gamificatio_user_id_860de2_idx'), models.Index(fields=['source_type', 'source_id'], name='gamificatio_source__6d5f84_idx')],
|
||||
'constraints': [models.CheckConstraint(condition=models.Q(('points', 0), _negated=True), name='gamification_nonzero_ledger_points')],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user