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


class Migration(migrations.Migration):
    """Additive: one new table for uptime samples."""

    dependencies = [
        ('ftlink', '0001_initial'),
        ('tenants', '0017_modulelog_acquisition'),
    ]

    operations = [
        migrations.CreateModel(
            name='UptimeSample',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('checked_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('ok', models.BooleanField(default=False)),
                ('status_code', models.PositiveSmallIntegerField(blank=True, null=True)),
                ('latency_ms', models.PositiveIntegerField(blank=True, null=True)),
                ('error', models.CharField(blank=True, max_length=200)),
                ('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                             related_name='uptime_samples', to='tenants.tenant')),
            ],
            options={
                'verbose_name': 'Uptime Sample',
                'verbose_name_plural': 'Uptime Samples',
                'ordering': ['-checked_at'],
            },
        ),
        migrations.AddIndex(
            model_name='uptimesample',
            index=models.Index(fields=['tenant', 'checked_at'], name='ftlink_upti_tenant__f1b2c3_idx'),
        ),
    ]
