# Generated by manual creation for database integration on 2025-08-20

import django.contrib.gis.db.models.fields
import django.contrib.postgres.indexes
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

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

    operations = [
        # Create Checkpoint model first (required by other operations)
        migrations.CreateModel(
            name='Checkpoint',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cp_number', models.IntegerField()),
                ('cp_name', models.CharField(blank=True, max_length=200, null=True)),
                ('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
                ('photo_point', models.IntegerField(default=0)),
                ('buy_point', models.IntegerField(default=0)),
                ('sample_photo', models.CharField(blank=True, max_length=500, null=True)),
                ('colabo_company_memo', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, blank=True, null=True)),
                ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rog.newevent2')),
            ],
        ),
        
        # Create GpsLog model for MobServer integration
        migrations.CreateModel(
            name='GpsLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('serial_number', models.IntegerField()),
                ('zekken_number', models.TextField()),
                ('event_code', models.TextField()),
                ('cp_number', models.TextField(blank=True, null=True)),
                ('image_address', models.TextField(blank=True, null=True)),
                ('checkin_time', models.DateTimeField(auto_now_add=True)),
                ('goal_time', models.TextField(blank=True, null=True)),
                ('late_point', models.IntegerField(blank=True, null=True)),
                ('create_at', models.DateTimeField(blank=True, null=True)),
                ('create_user', models.TextField(blank=True, null=True)),
                ('update_at', models.DateTimeField(blank=True, null=True)),
                ('update_user', models.TextField(blank=True, null=True)),
                ('buy_flag', models.BooleanField(blank=True, null=True)),
                ('minus_photo_flag', models.BooleanField(blank=True, null=True)),
                ('colabo_company_memo', models.TextField(default='')),
                ('is_service_checked', models.BooleanField(default=False)),
                ('score', models.IntegerField(blank=True, default=0, null=True)),
                ('scoreboard_url', models.URLField(blank=True, null=True)),
            ],
            options={
                'db_table': 'gps_information',
            },
        ),
        
        # Add fields to GpsCheckin model
        migrations.AddField(
            model_name='gpscheckin',
            name='checkpoint',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rog.checkpoint'),
        ),
        migrations.AddField(
            model_name='gpscheckin',
            name='minus_photo_flag',
            field=models.BooleanField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='gpscheckin',
            name='serial_number',
            field=models.IntegerField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='gpscheckin',
            name='team',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rog.team'),
        ),
        
        # Add fields to NewEvent2 model
        migrations.AddField(
            model_name='newevent2',
            name='event_code',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='newevent2',
            name='event_day',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='newevent2',
            name='start_time',
            field=models.TimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='newevent2',
            name='venue_address',
            field=models.CharField(blank=True, max_length=500, null=True),
        ),
        migrations.AddField(
            model_name='newevent2',
            name='venue_location',
            field=django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326),
        ),
        
        # Add fields to Team model
        migrations.AddField(
            model_name='team',
            name='class_name',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='team',
            name='event',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rog.newevent2'),
        ),
        migrations.AddField(
            model_name='team',
            name='location',
            field=django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326),
        ),
        migrations.AddField(
            model_name='team',
            name='password',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='team',
            name='trial',
            field=models.BooleanField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='team',
            name='zekken_number',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        
        # Add constraints for Checkpoint model
        migrations.AddConstraint(
            model_name='checkpoint',
            constraint=models.UniqueConstraint(fields=['cp_number', 'event'], name='unique_cp_per_event'),
        ),
        
        # Create indexes (use appropriate operator classes)
        migrations.AddIndex(
            model_name='checkpoint',
            index=models.Index(fields=['event', 'cp_number'], name='idx_checkpoint_event_cp'),
        ),
        migrations.AddIndex(
            model_name='gpslog',
            index=models.Index(fields=['serial_number'], name='gps_informa_serial__77a095_idx'),
        ),
        migrations.AddIndex(
            model_name='gpslog',
            index=models.Index(fields=['zekken_number'], name='gps_informa_zekken__01b27e_idx'),
        ),
        migrations.AddIndex(
            model_name='gpslog',
            index=models.Index(fields=['event_code'], name='gps_informa_event_c_2ab906_idx'),
        ),
        migrations.AddIndex(
            model_name='gpslog',
            index=models.Index(fields=['cp_number'], name='gps_informa_cp_numb_97c5c5_idx'),
        ),
        migrations.AddIndex(
            model_name='newevent2',
            index=models.Index(fields=['event_code'], name='rog_neweven_event_c_e79a96_idx'),
        ),
        migrations.AddIndex(
            model_name='team',
            index=models.Index(fields=['zekken_number'], name='rog_team_zekken__2c50d1_idx'),
        ),
    ]
