Files
rogaining_srv/rog/migrations/0011_auto_20250827_1459.py

213 lines
11 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Generated by Django 3.2.9 on 2025-08-27 05:59
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('rog', '0010_auto_20250827_1510'),
]
operations = [
migrations.CreateModel(
name='AppVersion',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.CharField(help_text='セマンティックバージョン (1.2.3)', max_length=20)),
('platform', models.CharField(choices=[('android', 'Android'), ('ios', 'iOS')], max_length=10)),
('build_number', models.CharField(blank=True, max_length=20, null=True)),
('is_latest', models.BooleanField(default=False, help_text='最新版フラグ')),
('is_required', models.BooleanField(default=False, help_text='強制更新フラグ')),
('update_message', models.TextField(blank=True, help_text='ユーザー向け更新メッセージ', null=True)),
('download_url', models.URLField(blank=True, help_text='アプリストアURL', null=True)),
('release_date', models.DateTimeField(default=django.utils.timezone.now)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'db_table': 'app_versions',
},
),
migrations.CreateModel(
name='CheckinExtended',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('gps_latitude', models.DecimalField(blank=True, decimal_places=8, max_digits=10, null=True)),
('gps_longitude', models.DecimalField(blank=True, decimal_places=8, max_digits=11, null=True)),
('gps_accuracy', models.DecimalField(blank=True, decimal_places=2, help_text='GPS精度メートル', max_digits=6, null=True)),
('gps_timestamp', models.DateTimeField(blank=True, null=True)),
('camera_capture_time', models.DateTimeField(blank=True, null=True)),
('device_info', models.TextField(blank=True, null=True)),
('validation_status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('requires_review', 'Requires Review')], default='pending', max_length=20)),
('validation_comment', models.TextField(blank=True, null=True)),
('validated_at', models.DateTimeField(blank=True, null=True)),
('bonus_points', models.IntegerField(default=0)),
('scoring_breakdown', models.JSONField(blank=True, default=dict)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'db_table': 'rog_checkin_extended',
},
),
migrations.CreateModel(
name='UploadedImage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('original_filename', models.CharField(max_length=255)),
('server_filename', models.CharField(max_length=255, unique=True)),
('file_url', models.URLField()),
('file_size', models.BigIntegerField()),
('mime_type', models.CharField(choices=[('image/jpeg', 'JPEG'), ('image/png', 'PNG'), ('image/heic', 'HEIC'), ('image/webp', 'WebP')], max_length=50)),
('event_code', models.CharField(blank=True, max_length=50, null=True)),
('team_name', models.CharField(blank=True, max_length=255, null=True)),
('cp_number', models.IntegerField(blank=True, null=True)),
('upload_source', models.CharField(choices=[('direct', 'Direct'), ('sharing_intent', 'Sharing Intent'), ('bulk_upload', 'Bulk Upload')], default='direct', max_length=50)),
('device_platform', models.CharField(blank=True, choices=[('ios', 'iOS'), ('android', 'Android'), ('web', 'Web')], max_length=20, null=True)),
('capture_timestamp', models.DateTimeField(blank=True, null=True)),
('upload_timestamp', models.DateTimeField(auto_now_add=True)),
('device_info', models.TextField(blank=True, null=True)),
('processing_status', models.CharField(choices=[('uploaded', 'Uploaded'), ('processing', 'Processing'), ('processed', 'Processed'), ('failed', 'Failed')], default='uploaded', max_length=20)),
('thumbnail_url', models.URLField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'db_table': 'rog_uploaded_images',
},
),
# TeamStartテーブルのentryカラムを安全に削除
migrations.RunSQL(
sql="""
DO $$
BEGIN
IF EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'rog_teamstart') THEN
IF EXISTS (SELECT FROM information_schema.columns WHERE table_name = 'rog_teamstart' AND column_name = 'entry_id') THEN
ALTER TABLE rog_teamstart DROP COLUMN entry_id;
END IF;
END IF;
END $$;
""",
reverse_sql="-- No reverse SQL needed for conditional operation"
),
migrations.AddField(
model_name='entry',
name='can_access_private_events',
field=models.BooleanField(default=False, help_text='非公開イベント参加権限'),
),
migrations.AddField(
model_name='entry',
name='staff_privileges',
field=models.BooleanField(default=False, help_text='スタッフ権限フラグ'),
),
migrations.AddField(
model_name='entry',
name='team_validation_status',
field=models.CharField(choices=[('approved', 'Approved'), ('pending', 'Pending'), ('rejected', 'Rejected')], default='approved', help_text='チーム承認状況', max_length=20),
),
migrations.AddField(
model_name='entry',
name='zekken_label',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='gpscheckin',
name='create_at',
field=models.DateTimeField(blank=True, help_text='作成日時:データの作成日時', null=True),
),
migrations.AddField(
model_name='gpscheckin',
name='create_user',
field=models.TextField(blank=True, help_text='作成ユーザー', null=True),
),
migrations.AddField(
model_name='gpscheckin',
name='event_id',
field=models.IntegerField(blank=True, help_text='イベントID', null=True),
),
migrations.AddField(
model_name='gpscheckin',
name='goal_time',
field=models.TextField(blank=True, help_text='ゴール時刻=ゴール時のみ使用される。画像から時刻を読み取り設定する。', null=True),
),
migrations.AddField(
model_name='gpscheckin',
name='image_address',
field=models.TextField(blank=True, help_text='チェックイン画像のパス', null=True),
),
migrations.AddField(
model_name='newevent2',
name='status',
field=models.CharField(choices=[('public', 'Public'), ('private', 'Private'), ('draft', 'Draft'), ('closed', 'Closed')], default='draft', help_text='イベントステータス', max_length=20),
),
migrations.AlterModelTable(
name='gpslog',
table='gps_information',
),
migrations.DeleteModel(
name='TeamGoal',
),
migrations.DeleteModel(
name='TeamStart',
),
migrations.AddField(
model_name='uploadedimage',
name='entry',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rog.entry'),
),
migrations.AddField(
model_name='uploadedimage',
name='gpslog',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rog.gpscheckin'),
),
migrations.AddField(
model_name='checkinextended',
name='gpslog',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extended_info', to='rog.gpscheckin'),
),
migrations.AddField(
model_name='checkinextended',
name='validated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddIndex(
model_name='appversion',
index=models.Index(fields=['platform'], name='idx_app_versions_platform'),
),
migrations.AddIndex(
model_name='appversion',
index=models.Index(condition=models.Q(('is_latest', True)), fields=['is_latest'], name='idx_app_versions_latest_true'),
),
migrations.AlterUniqueTogether(
name='appversion',
unique_together={('version', 'platform')},
),
migrations.AddIndex(
model_name='uploadedimage',
index=models.Index(fields=['event_code', 'team_name'], name='idx_uploaded_event_team'),
),
migrations.AddIndex(
model_name='uploadedimage',
index=models.Index(fields=['cp_number'], name='idx_uploaded_cp_number'),
),
migrations.AddIndex(
model_name='uploadedimage',
index=models.Index(fields=['upload_timestamp'], name='idx_uploaded_timestamp'),
),
migrations.AddIndex(
model_name='uploadedimage',
index=models.Index(fields=['processing_status'], name='idx_uploaded_status'),
),
migrations.AddIndex(
model_name='checkinextended',
index=models.Index(fields=['validation_status'], name='idx_checkin_ext_valid'),
),
migrations.AddIndex(
model_name='checkinextended',
index=models.Index(fields=['created_at'], name='idx_checkin_ext_created'),
),
]