feat: add billing pricing rules
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# Generated by Django 5.2.15 on 2026-07-02 07:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ExchangeRate',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('currency', models.CharField(default='CNY', max_length=10)),
|
||||
('points_per_unit', models.DecimalField(decimal_places=4, max_digits=12)),
|
||||
('is_active', models.BooleanField(default=True)),
|
||||
('effective_from', models.DateTimeField()),
|
||||
('note', models.CharField(blank=True, max_length=255)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'exchange_rate',
|
||||
'ordering': ('-effective_from', '-id'),
|
||||
'indexes': [models.Index(fields=['currency', 'is_active', 'effective_from'], name='exchange_ra_currenc_d69abe_idx')],
|
||||
'constraints': [models.CheckConstraint(condition=models.Q(('points_per_unit__gt', 0)), name='exchange_rate_points_per_unit_positive')],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='PricingRule',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('operation_type', models.CharField(choices=[('title', 'Generate title'), ('image', 'Generate image')], max_length=32)),
|
||||
('alias', models.CharField(max_length=64)),
|
||||
('resolution', models.CharField(blank=True, default='', help_text='Leave blank to apply to every resolution for this alias.', max_length=32)),
|
||||
('points_cost', models.BigIntegerField()),
|
||||
('is_active', models.BooleanField(default=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'pricing_rule',
|
||||
'ordering': ('operation_type', 'alias', 'resolution'),
|
||||
'indexes': [models.Index(fields=['operation_type', 'alias', 'is_active'], name='pricing_rul_operati_580547_idx'), models.Index(fields=['operation_type', 'alias', 'resolution', 'is_active'], name='pricing_rul_operati_52be66_idx')],
|
||||
'constraints': [models.UniqueConstraint(fields=('operation_type', 'alias', 'resolution'), name='unique_pricing_rule_per_alias_resolution'), models.CheckConstraint(condition=models.Q(('points_cost__gt', 0)), name='pricing_rule_points_cost_positive')],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user