# Generated by Django 5.2.12 on 2026-09-10 13:51 import django.db.models.deletion from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ('core', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Plan', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('code', models.CharField(max_length=32, unique=True)), ('name', models.CharField(max_length=64)), ('price_monthly', models.DecimalField(decimal_places=2, default=0, help_text='月费(元);0 = 免费', max_digits=10)), ('limits', models.JSONField(default=dict, help_text='配额与功能开关(唯一事实来源)')), ('description', models.CharField(blank=True, default='', max_length=255)), ('sort_order', models.IntegerField(default=0)), ('is_active', models.BooleanField(default=True)), ], options={ 'verbose_name_plural': '套餐', 'db_table': 'billing_plan', 'ordering': ['sort_order', 'code'], }, ), migrations.CreateModel( name='Subscription', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('is_deleted', models.BooleanField(default=False)), ('deleted_at', models.DateTimeField(blank=True, null=True)), ('ext_data', models.JSONField(blank=True, default=dict)), ('source_channel', models.CharField(blank=True, default='manual', max_length=32)), ('status', models.CharField(choices=[('trial', '试用中'), ('active', '已订阅'), ('expired', '已过期')], default='trial', max_length=16)), ('trial_ends_at', models.DateTimeField(blank=True, null=True)), ('period_start', models.DateField(blank=True, null=True)), ('period_end', models.DateField(blank=True, null=True)), ('remark', models.TextField(blank=True, default='')), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)), ('org', models.ForeignKey(blank=True, help_text='所属组织(多机构预留)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.org')), ('plan', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='subscriptions', to='billing.plan')), ('tenant', models.ForeignKey(help_text='所属租户', on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.tenant')), ('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name_plural': '订阅', 'db_table': 'billing_subscription', 'ordering': ['-created_at'], }, ), ]