Backend (Django 4.2 + DRF): - accounts: phone OTP login, JWT, profile, addresses - catalog: categories, products, images, filters, search, hits/new/related - orders: creation with Idempotency-Key, stock reservation, status history, cancel - loyalty: bonus accounts, promo codes, gift certificates - payments: payment records and YooKassa webhook handling - content: static pages, banners, site settings - integration: 1C exchange (catalog sync, order push via outbox, statuses, bonuses) - common: error envelope, pagination, request-id, integration auth, admin dashboard Infrastructure: Dockerfile, docker-compose (Postgres, Redis, Celery worker/beat, Nginx), requirements split by environment, OpenAPI contracts for site and 1C, architecture doc. Tests: 22 pytest cases covering catalog, orders, idempotency, OTP, integration.
95 lines
5.2 KiB
Python
95 lines
5.2 KiB
Python
# Generated by Django 4.2.16 on 2026-11-06 13:26
|
||
|
||
from django.db import migrations, models
|
||
import django.db.models.deletion
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
|
||
initial = True
|
||
|
||
dependencies = [
|
||
]
|
||
|
||
operations = [
|
||
migrations.CreateModel(
|
||
name='IdempotencyKey',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True)),
|
||
('key', models.CharField(max_length=128, unique=True)),
|
||
('scope', models.CharField(max_length=64)),
|
||
('status_code', models.PositiveSmallIntegerField(default=200)),
|
||
('response', models.JSONField(blank=True, default=dict)),
|
||
],
|
||
options={
|
||
'verbose_name': 'ключ идемпотентности',
|
||
'verbose_name_plural': 'ключи идемпотентности',
|
||
'db_table': 'integration_idempotency_key',
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='SyncRun',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True)),
|
||
('direction', models.CharField(choices=[('inbound', '1С → сайт'), ('outbound', 'Сайт → 1С')], max_length=10)),
|
||
('entity', models.CharField(choices=[('catalog', 'Каталог'), ('orders', 'Заказы'), ('statuses', 'Статусы'), ('customers', 'Клиенты'), ('bonuses', 'Бонусы')], max_length=20)),
|
||
('status', models.CharField(choices=[('running', 'Выполняется'), ('success', 'Успешно'), ('partial', 'Частично'), ('failed', 'Ошибка')], default='running', max_length=10)),
|
||
('started_at', models.DateTimeField()),
|
||
('finished_at', models.DateTimeField(blank=True, null=True)),
|
||
('stats', models.JSONField(blank=True, default=dict)),
|
||
('error', models.TextField(blank=True)),
|
||
],
|
||
options={
|
||
'verbose_name': 'сеанс обмена',
|
||
'verbose_name_plural': 'сеансы обмена',
|
||
'db_table': 'integration_sync_run',
|
||
'ordering': ['-started_at'],
|
||
'indexes': [models.Index(fields=['entity', 'started_at'], name='integration_entity_5810cd_idx')],
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='SyncLog',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True)),
|
||
('level', models.CharField(choices=[('debug', 'Debug'), ('info', 'Info'), ('warning', 'Warning'), ('error', 'Error')], default='info', max_length=10)),
|
||
('message', models.TextField()),
|
||
('payload', models.JSONField(blank=True, default=dict)),
|
||
('run', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='integration.syncrun')),
|
||
],
|
||
options={
|
||
'verbose_name': 'запись журнала обмена',
|
||
'verbose_name_plural': 'журнал обмена',
|
||
'db_table': 'integration_sync_log',
|
||
'ordering': ['created_at'],
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='OutboxMessage',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True)),
|
||
('topic', models.CharField(max_length=64)),
|
||
('payload', models.JSONField(default=dict)),
|
||
('status', models.CharField(choices=[('pending', 'Ожидает'), ('sent', 'Отправлено'), ('failed', 'Ошибка'), ('dead', 'Исчерпаны попытки')], default='pending', max_length=10)),
|
||
('attempts', models.PositiveSmallIntegerField(default=0)),
|
||
('next_attempt_at', models.DateTimeField(blank=True, null=True)),
|
||
('last_error', models.TextField(blank=True)),
|
||
('sent_at', models.DateTimeField(blank=True, null=True)),
|
||
],
|
||
options={
|
||
'verbose_name': 'сообщение outbox',
|
||
'verbose_name_plural': 'сообщения outbox',
|
||
'db_table': 'integration_outbox_message',
|
||
'ordering': ['created_at'],
|
||
'indexes': [models.Index(fields=['status', 'next_attempt_at'], name='integration_status_025e86_idx')],
|
||
},
|
||
),
|
||
]
|