# Generated by Django 5.2.8 on 2025-11-20 23:27

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('igny8_core_auth', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='SiteIntegration',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('platform', models.CharField(choices=[('wordpress', 'WordPress'), ('shopify', 'Shopify'), ('custom', 'Custom API')], db_index=True, help_text="Platform name: 'wordpress', 'shopify', 'custom'", max_length=50)),
                ('platform_type', models.CharField(choices=[('cms', 'CMS'), ('ecommerce', 'Ecommerce'), ('custom_api', 'Custom API')], default='cms', help_text="Platform type: 'cms', 'ecommerce', 'custom_api'", max_length=50)),
                ('config_json', models.JSONField(default=dict, help_text='Platform-specific configuration (URLs, endpoints, etc.)')),
                ('credentials_json', models.JSONField(default=dict, help_text='Encrypted credentials (API keys, tokens, etc.)')),
                ('is_active', models.BooleanField(db_index=True, default=True, help_text='Whether this integration is active')),
                ('sync_enabled', models.BooleanField(default=False, help_text='Whether two-way sync is enabled')),
                ('last_sync_at', models.DateTimeField(blank=True, help_text='Last successful sync timestamp', null=True)),
                ('sync_status', models.CharField(choices=[('success', 'Success'), ('failed', 'Failed'), ('pending', 'Pending'), ('syncing', 'Syncing')], db_index=True, default='pending', help_text='Current sync status', max_length=20)),
                ('sync_error', models.TextField(blank=True, help_text='Last sync error message', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('site', models.ForeignKey(help_text='Site this integration belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='integrations', to='igny8_core_auth.site')),
            ],
            options={
                'db_table': 'igny8_site_integrations',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['site', 'platform'], name='igny8_site__site_id_3901ba_idx'), models.Index(fields=['site', 'is_active'], name='igny8_site__site_id_71bc1a_idx'), models.Index(fields=['account', 'platform'], name='igny8_site__tenant__920542_idx'), models.Index(fields=['sync_status'], name='igny8_site__sync_st_e79021_idx')],
                'unique_together': {('site', 'platform')},
            },
        ),
    ]
