# Generated by Django 2.2.5 on 2019-10-06 20:31

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('authentication', '0016_ownershiprecord'),
        ('eveonline', '0010_alliance_ticker'),
    ]

    operations = [
        migrations.CreateModel(
            name='Freight',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
            options={
                'default_permissions': (),
                'permissions': (('basic_access', 'Can access this app'), ('setup_contract_handler', 'Can setup contract handler'), ('use_calculator', 'Can use the calculator'), ('view_contracts', 'Can view the contracts list'), ('add_location', 'Can add / update locations'), ('view_statistics', 'Can view freight statistics')),
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Location',
            fields=[
                ('id', models.BigIntegerField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=100)),
                ('solar_system_id', models.IntegerField(blank=True, default=None, null=True)),
                ('type_id', models.IntegerField(blank=True, default=None, null=True)),
                ('category_id', models.IntegerField(choices=[(3, 'station'), (65, 'structure'), (0, '(unknown)')], default=0)),
            ],
        ),
        migrations.CreateModel(
            name='Pricing',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('active', models.BooleanField(default=True, help_text='Non active pricings will not be used or shown')),
                ('price_base', models.FloatField(blank=True, default=0, help_text='Base price in ISK')),
                ('price_per_volume', models.FloatField(blank=True, default=0, help_text='Add-on price per m3 volume in ISK')),
                ('price_per_collateral_percent', models.FloatField(blank=True, default=0, help_text='Add-on price in % of collaterial')),
                ('collateral_min', models.BigIntegerField(blank=True, default=0, help_text='Minimum required collateral in ISK')),
                ('collateral_max', models.BigIntegerField(blank=True, default=None, help_text='Maximum allowed collateral in ISK', null=True)),
                ('volume_max', models.FloatField(blank=True, default=None, help_text='Maximum allowed volume in m3', null=True)),
                ('days_to_expire', models.IntegerField(blank=True, default=None, help_text='Recommended days for contracts to expire', null=True)),
                ('days_to_complete', models.IntegerField(blank=True, default=None, help_text='Recommended days for contract completion', null=True)),
                ('details', models.TextField(blank=True, default=None, help_text='Text with additional instructions for using this pricing', null=True)),
                ('end_location', models.ForeignKey(help_text='Destination station or structure for courier route', on_delete=django.db.models.deletion.CASCADE, related_name='pricing_end_location', to='freight.Location')),
                ('start_location', models.ForeignKey(help_text='Starting station or structure for courier route', on_delete=django.db.models.deletion.CASCADE, related_name='pricing_start_location', to='freight.Location')),
            ],
            options={
                'unique_together': {('start_location', 'end_location')},
            },
        ),
        migrations.CreateModel(
            name='ContractHandler',
            fields=[
                ('alliance', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='eveonline.EveAllianceInfo')),
                ('version_hash', models.CharField(blank=True, default=None, max_length=32, null=True)),
                ('last_sync', models.DateTimeField(blank=True, default=None, null=True)),
                ('character', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='authentication.CharacterOwnership')),
            ],
        ),
        migrations.CreateModel(
            name='Contract',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('contract_id', models.IntegerField()),
                ('collateral', models.FloatField()),
                ('date_accepted', models.DateTimeField(default=None, null=True)),
                ('date_completed', models.DateTimeField(default=None, null=True)),
                ('date_expired', models.DateTimeField()),
                ('date_issued', models.DateTimeField()),
                ('days_to_complete', models.IntegerField()),
                ('for_corporation', models.BooleanField()),
                ('price', models.FloatField()),
                ('reward', models.FloatField()),
                ('status', models.CharField(choices=[('outstanding', 'outstanding'), ('in_progress', 'in progress'), ('finished_issuer', 'finished issuer'), ('finished_contractor', 'finished contractor'), ('finished', 'finished'), ('canceled', 'canceled'), ('rejected', 'rejected'), ('failed', 'failed'), ('deleted', 'deleted'), ('reversed', 'reversed')], max_length=32)),
                ('title', models.CharField(default=None, max_length=100, null=True)),
                ('volume', models.FloatField()),
                ('date_notified', models.DateTimeField(default=None, help_text='datetime of latest notification, None = none has been sent', null=True)),
                ('acceptor', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='contract_acceptor', to='eveonline.EveCharacter')),
                ('end_location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contract_end_location', to='freight.Location')),
                ('handler', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='freight.ContractHandler')),
                ('issuer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contract_issuer', to='eveonline.EveCharacter')),
                ('issuer_corporation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contract_issuer', to='eveonline.EveCorporationInfo')),
                ('pricing', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='freight.Pricing')),
                ('start_location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contract_start_location', to='freight.Location')),
            ],
        ),
        migrations.AddIndex(
            model_name='contract',
            index=models.Index(fields=['status'], name='freight_con_status_b4eb08_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='contract',
            unique_together={('handler', 'contract_id')},
        ),
        migrations.AlterField(
            model_name='location',
            name='id',
            field=models.BigIntegerField(primary_key=True, serialize=False, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='collateral_min',
            field=models.BigIntegerField(blank=True, default=None, help_text='Minimum required collateral in ISK', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='days_to_complete',
            field=models.IntegerField(blank=True, default=None, help_text='Recommended days for contract completion', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='days_to_expire',
            field=models.IntegerField(blank=True, default=None, help_text='Recommended days for contracts to expire', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='price_base',
            field=models.FloatField(blank=True, default=None, help_text='Base price in ISK', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='pricing',
            name='price_min',
            field=models.FloatField(blank=True, default=None, help_text='Minimum total price in ISK', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='price_per_collateral_percent',
            field=models.FloatField(blank=True, default=None, help_text='Add-on price in % of collaterial', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='price_per_volume',
            field=models.FloatField(blank=True, default=None, help_text='Add-on price per m3 volume in ISK', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='collateral_max',
            field=models.BigIntegerField(blank=True, default=None, help_text='Maximum allowed collateral in ISK', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='days_to_complete',
            field=models.IntegerField(blank=True, default=None, help_text='Recommended days for contract completion', null=True, validators=[django.core.validators.MinValueValidator(1)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='days_to_expire',
            field=models.IntegerField(blank=True, default=None, help_text='Recommended days for contracts to expire', null=True, validators=[django.core.validators.MinValueValidator(1)]),
        ),
        migrations.AlterField(
            model_name='pricing',
            name='volume_max',
            field=models.FloatField(blank=True, default=None, help_text='Maximum allowed volume in m3', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='pricing',
            name='volume_min',
            field=models.FloatField(blank=True, default=None, help_text='Minimum allowed volume in m3', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterModelOptions(
            name='freight',
            options={'default_permissions': (), 'managed': False, 'permissions': (('add_location', 'Can add / update locations'), ('basic_access', 'Can access this app'), ('setup_contract_handler', 'Can setup contract handler'), ('use_calculator', 'Can use the calculator'), ('view_contracts', 'Can view the contracts list'), ('view_statistics', 'Can view freight statistics'))},
        ),
        migrations.RemoveField(
            model_name='contract',
            name='date_notified',
        ),
        migrations.AddField(
            model_name='contract',
            name='issues',
            field=models.TextField(default=None, help_text='List or price check issues as JSON array of strings or None', null=True),
        ),
        migrations.AddField(
            model_name='contracthandler',
            name='last_error',
            field=models.IntegerField(choices=[(0, 'No error'), (1, 'Invalid token'), (2, 'Expired token'), (3, 'Insufficient permissions'), (4, 'No character set for fetching alliance contacts'), (5, 'ESI API is currently unavailable'), (99, 'Unknown error')], default=0, help_text='error that occurred at the last sync atttempt (if any)'),
        ),
        migrations.AlterField(
            model_name='contracthandler',
            name='last_sync',
            field=models.DateTimeField(blank=True, default=None, help_text='when the last sync happened', null=True),
        ),
        migrations.AlterField(
            model_name='contracthandler',
            name='version_hash',
            field=models.CharField(blank=True, default=None, help_text='hash to identify changes to contracts', max_length=32, null=True),
        ),
        migrations.AlterField(
            model_name='location',
            name='category_id',
            field=models.IntegerField(choices=[(3, 'station'), (65, 'structure'), (0, '(unknown)')], default=0, help_text='Eve Online category ID', validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='location',
            name='id',
            field=models.BigIntegerField(help_text='Eve Online location ID, either item ID for stations or structure ID for structures', primary_key=True, serialize=False, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='location',
            name='name',
            field=models.CharField(help_text='In-game name of this station or structure', max_length=100),
        ),
        migrations.AlterField(
            model_name='location',
            name='solar_system_id',
            field=models.IntegerField(blank=True, default=None, help_text='Eve Online solar system ID', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AlterField(
            model_name='location',
            name='type_id',
            field=models.IntegerField(blank=True, default=None, help_text='Eve Online type ID', null=True, validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='contract',
            name='date_notified',
            field=models.DateTimeField(default=None, help_text='datetime of latest notification, None = none has been sent', null=True),
        ),
    ]
