44 lines
2.3 KiB
Python
44 lines
2.3 KiB
Python
# Generated by Django 6.1 on 2026-08-18 02:33
|
|
|
|
import django.db.models.deletion
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('discount', '0002_redemption_unique_redemption_per_user_per_code'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='Offer',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(max_length=100)),
|
|
('kind', models.CharField(choices=[('trial', 'دوره\u200cی رایگان محدود'), ('free_full', 'دسترسی کامل رایگان')], max_length=10)),
|
|
('duration_days', models.PositiveIntegerField(blank=True, null=True)),
|
|
('code', models.CharField(blank=True, max_length=30, null=True, unique=True)),
|
|
('auto_assign_on_signup', models.BooleanField(default=False)),
|
|
('is_active', models.BooleanField(default=True)),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='UserOffer',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('user_id', models.IntegerField(db_index=True)),
|
|
('source', models.CharField(choices=[('signup_auto', 'خودکار هنگام ثبت\u200cنام'), ('code', 'وارد کردن کد'), ('manual', 'اختصاص دستی/پشتیبانی')], max_length=15)),
|
|
('status', models.CharField(choices=[('active', 'فعال'), ('expired', 'منقضی'), ('revoked', 'لغوشده')], default='active', max_length=10)),
|
|
('granted_at', models.DateTimeField(auto_now_add=True)),
|
|
('expires_at', models.DateTimeField(blank=True, null=True)),
|
|
('offer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_offers', to='discount.offer')),
|
|
],
|
|
options={
|
|
'ordering': ['-granted_at'],
|
|
'constraints': [models.UniqueConstraint(fields=('offer', 'user_id'), name='unique_offer_per_user')],
|
|
},
|
|
),
|
|
]
|