# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-08-24 15:29
from __future__ import unicode_literals

import datetime
from django.db import migrations, models
from stratosource.models import ConfigSetting
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    def populate_configs(apps, schema_editor):
        import uuid

        ConfigSetting(key='uuid', value=uuid.uuid1(), allow_delete=False, masked=False).save()
        for name in 'rally.login,email.host,email.from'.split(','):
            ConfigSetting(key=name, value='', allow_delete=False, masked=False).save()
        for name in 'rally.enabled,agilezen.enabled'.split(','):
            ConfigSetting(key=name, value='', type='check', allow_delete=False, masked=False).save()
        for name in 'rally.password,agilezen.apikey'.split(','):
            ConfigSetting(key=name, value='', allow_delete=False, masked=True).save()


    operations = [
        migrations.CreateModel(
            name='AdminMessage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('to', models.CharField(default=b'any', max_length=50)),
                ('sender', models.CharField(default=b'unknown', max_length=50)),
                ('subject', models.CharField(max_length=100)),
                ('body', models.CharField(max_length=255)),
                ('event_time', models.DateField(default=datetime.datetime.now)),
                ('handled_by', models.CharField(max_length=100)),
            ],
            options={
                'db_table': 'admin_message',
            },
        ),
        migrations.CreateModel(
            name='Branch',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.IntegerField(default=0)),
                ('name', models.CharField(max_length=30)),
                ('api_env', models.CharField(default=b'test', max_length=10)),
                ('api_pod', models.CharField(default=b'cs4', max_length=10)),
                ('api_user', models.CharField(max_length=100)),
                ('api_pass', models.CharField(blank=True, max_length=100, null=True)),
                ('api_auth', models.CharField(blank=True, max_length=50, null=True)),
                ('api_store', models.CharField(default=b'/var/sftmp', max_length=100)),
                ('api_assets', models.CharField(default=b'CustomPageWebLink,CustomLabels,CustomApplication,CustomObject,CustomObjectTranslation,Translations,CustomSite,CustomTab,Layout,Portal,Profile,RemoteSiteSetting,ReportType,Workflow', max_length=500)),
                ('enabled', models.BooleanField(default=True)),
                ('cron_enabled', models.BooleanField(default=False)),
                ('cron_type', models.CharField(choices=[(b'h', b'Hourly'), (b'd', b'Daily')], default=b'h', max_length=1)),
                ('run_status', models.CharField(blank=True, choices=[(b'u', b'Unknown'), (b'r', b'Running'), (b'd', b'Done'), (b'e', b'Error')], default=b'u', max_length=1, null=True)),
                ('cron_interval', models.IntegerField(default=1)),
                ('cron_start', models.CharField(default=b'0', max_length=5)),
                ('keep_archive', models.BooleanField(default=False)),
                ('code_cron_enabled', models.BooleanField(default=False)),
                ('code_cron_type', models.CharField(choices=[(b'h', b'Hourly'), (b'd', b'Daily')], default=b'h', max_length=1)),
                ('code_run_status', models.CharField(blank=True, choices=[(b'u', b'Unknown'), (b'r', b'Running'), (b'd', b'Done'), (b'e', b'Error')], default=b'u', max_length=1, null=True)),
                ('code_cron_interval', models.IntegerField(default=1)),
                ('code_cron_start', models.CharField(default=b'0', max_length=5)),
                ('code_keep_archive', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'branch',
            },
        ),
        migrations.CreateModel(
            name='BranchLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('lastlog', models.CharField(max_length=20000)),
                ('logtype', models.CharField(max_length=6)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'branch_log',
            },
        ),
        migrations.CreateModel(
            name='BranchStats',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cls_files', models.IntegerField()),
                ('cls_lines', models.IntegerField()),
                ('cls_bytes', models.IntegerField()),
                ('page_files', models.IntegerField()),
                ('page_lines', models.IntegerField()),
                ('page_bytes', models.IntegerField()),
                ('trigger_files', models.IntegerField()),
                ('trigger_lines', models.IntegerField()),
                ('trigger_bytes', models.IntegerField()),
                ('files', models.IntegerField()),
                ('lines', models.IntegerField()),
                ('bytes', models.IntegerField()),
                ('last_updated', models.DateTimeField(default=datetime.datetime.now)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'branch_stats',
            },
        ),
        migrations.CreateModel(
            name='Commit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('hash', models.CharField(db_index=True, max_length=100)),
                ('prev_hash', models.CharField(max_length=100)),
                ('comment', models.CharField(blank=True, max_length=200, null=True)),
                ('date_added', models.DateTimeField(default=datetime.datetime.now)),
                ('status', models.CharField(choices=[(b'p', b'Pending Analysis'), (b'c', b'Complete')], default=b'p', max_length=1)),
                ('parser_ver', models.CharField(default=b'01', max_length=2)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'commit',
            },
        ),
        migrations.CreateModel(
            name='ConfigSetting',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=250, unique=True)),
                ('value', models.CharField(blank=True, max_length=1000, null=True)),
                ('type', models.CharField(default=b'text', max_length=20)),
                ('allow_delete', models.BooleanField(default=True)),
                ('masked', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'config_setting',
            },
        ),
        migrations.CreateModel(
            name='Delta',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('delta_type', models.CharField(choices=[(b'a', b'Add'), (b'd', b'Delete'), (b'u', b'Update')], max_length=1)),
                ('commit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Commit')),
            ],
            options={
                'db_table': 'delta',
            },
        ),
        migrations.CreateModel(
            name='DeployableObject',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('filename', models.CharField(db_index=True, max_length=200)),
                ('type', models.CharField(db_index=True, max_length=20)),
                ('el_type', models.CharField(blank=True, max_length=20, null=True)),
                ('el_subtype', models.CharField(blank=True, max_length=20, null=True)),
                ('el_name', models.CharField(blank=True, max_length=100, null=True)),
                ('status', models.CharField(choices=[(b'a', b'Active'), (b'd', b'Deleted')], default=b'a', max_length=1)),
                ('release_status', models.CharField(choices=[(b'r', b'Released'), (b'c', b'Changed'), (b'p', b'Pending Release'), (b'e', b'Conflicting')], default=b'r', max_length=1)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'deployable_object',
            },
        ),
        migrations.CreateModel(
            name='DeployableTranslation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.CharField(max_length=200)),
                ('locale', models.CharField(max_length=10)),
                ('status', models.CharField(choices=[(b'a', b'Active'), (b'd', b'Deleted')], default=b'a', max_length=1)),
                ('release_status', models.CharField(choices=[(b'r', b'Released'), (b'c', b'Changed'), (b'p', b'Pending Release'), (b'e', b'Conflicting')], default=b'r', max_length=1)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'deployable_translation',
            },
        ),
        migrations.CreateModel(
            name='DeploymentPackage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=1000)),
                ('date_added', models.DateTimeField(default=datetime.datetime.now)),
                ('last_pushed', models.DateTimeField(null=True)),
                ('deployable_objects', models.ManyToManyField(to='stratosource.DeployableObject')),
            ],
            options={
                'db_table': 'deployment_package',
            },
        ),
        migrations.CreateModel(
            name='DeploymentPushStatus',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date_attempted', models.DateField(default=datetime.datetime.now)),
                ('log_output', models.CharField(max_length=20000)),
                ('result', models.CharField(choices=[(b'n', b'New'), (b'i', b'In Progress'), (b's', b'Successful'), (b'f', b'Failed')], default=b'n', max_length=1)),
                ('test_only', models.BooleanField(default=True)),
                ('keep_package', models.BooleanField(default=False)),
                ('package_location', models.CharField(max_length=200, null=True)),
                ('package', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.DeploymentPackage')),
                ('target_environment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='from_deployment_packages', to='stratosource.Branch')),
            ],
            options={
                'db_table': 'deployment_push_status',
            },
        ),
        migrations.CreateModel(
            name='Release',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('release_notes', models.CharField(max_length=4000)),
                ('est_release_date', models.DateField(blank=True, null=True)),
                ('release_date', models.DateField(blank=True, null=True)),
                ('released', models.BooleanField(default=False)),
                ('hidden', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'release',
            },
        ),
        migrations.CreateModel(
            name='ReleaseTask',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('task_type', models.IntegerField(choices=[(100, b'UNSPECIFIED'), (0, b'MANIFEST'), (20, b'PRE-VALIDATION'), (40, b'PRE-RELEASE'), (60, b'RELEASE'), (80, b'POST-RELEASE')], default=100)),
                ('name', models.CharField(max_length=1000)),
                ('done_in_branch', models.CharField(max_length=100)),
                ('order', models.IntegerField(default=0)),
                ('release', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='stratosource.Release')),
            ],
            options={
                'db_table': 'release_task',
            },
        ),
        migrations.CreateModel(
            name='Repo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=20)),
                ('location', models.CharField(blank=True, max_length=255, null=True)),
            ],
            options={
                'db_table': 'repo',
            },
        ),
        migrations.CreateModel(
            name='SalesforceUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('userid', models.CharField(max_length=20)),
                ('name', models.CharField(db_index=True, max_length=100)),
                ('email', models.CharField(max_length=100)),
                ('lastActive', models.DateTimeField(default=datetime.datetime.now, null=True)),
            ],
            options={
                'db_table': 'salesforce_user',
            },
        ),
        migrations.CreateModel(
            name='Story',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rally_id', models.CharField(blank=True, max_length=20, null=True)),
                ('sprint', models.CharField(max_length=255)),
                ('name', models.CharField(max_length=255)),
                ('url', models.CharField(blank=True, max_length=1024, null=True)),
                ('release_date', models.DateField(blank=True, null=True)),
                ('released', models.BooleanField(default=False)),
                ('date_added', models.DateField(default=datetime.datetime.now)),
                ('done_on_branches', models.ManyToManyField(to='stratosource.Branch')),
            ],
            options={
                'db_table': 'story',
            },
        ),
        migrations.CreateModel(
            name='TranslationDelta',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('delta_type', models.CharField(choices=[(b'a', b'Add'), (b'd', b'Delete'), (b'u', b'Update')], max_length=1)),
                ('commit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Commit')),
                ('translation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.DeployableTranslation')),
            ],
            options={
                'db_table': 'translation_delta',
            },
        ),
        migrations.CreateModel(
            name='UnitTestBatch',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('batch_time', models.DateTimeField(db_index=True, default=datetime.datetime.now)),
                ('tests', models.IntegerField(default=0)),
                ('failures', models.IntegerField(default=0)),
                ('runtime', models.IntegerField(default=0)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'unit_test_batch',
            },
        ),
        migrations.CreateModel(
            name='UnitTestRun',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('apex_class_id', models.CharField(max_length=20)),
                ('class_name', models.CharField(max_length=200)),
                ('tests', models.IntegerField(default=0)),
                ('failures', models.IntegerField(default=0)),
                ('runtime', models.IntegerField(default=0)),
                ('batch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.UnitTestBatch')),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'unit_test_run',
            },
        ),
        migrations.CreateModel(
            name='UnitTestRunResult',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_time', models.DateTimeField()),
                ('end_time', models.DateTimeField()),
                ('method_name', models.CharField(max_length=200)),
                ('outcome', models.CharField(max_length=50)),
                ('message', models.CharField(blank=True, max_length=255, null=True)),
                ('runtime', models.IntegerField(default=0)),
                ('test_run', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.UnitTestRun')),
            ],
            options={
                'db_table': 'unit_test_run_result',
            },
        ),
        migrations.CreateModel(
            name='UnitTestSchedule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('results_email_address', models.CharField(max_length=500)),
                ('email_only_failures', models.BooleanField(default=True)),
                ('cron_enabled', models.BooleanField(default=True)),
                ('cron_type', models.CharField(choices=[(b'h', b'Hourly'), (b'd', b'Daily'), (b'w', b'Weeky')], default=b'd', max_length=1)),
                ('cron_interval', models.IntegerField(default=1)),
                ('cron_start', models.CharField(default=b'0', max_length=5)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
            ],
            options={
                'db_table': 'unit_test_schedule',
            },
        ),
        migrations.CreateModel(
            name='UserChange',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('apex_id', models.CharField(blank=True, max_length=20, null=True)),
                ('apex_name', models.CharField(db_index=True, max_length=200)),
                ('batch_time', models.DateTimeField()),
                ('last_update', models.DateTimeField()),
                ('object_type', models.CharField(max_length=20)),
                ('branch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Branch')),
                ('sfuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.SalesforceUser')),
            ],
            options={
                'db_table': 'user_change',
            },
        ),
        migrations.AddField(
            model_name='releasetask',
            name='story',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='releasetask',
            name='user',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='stratosource.SalesforceUser'),
        ),
        migrations.AddField(
            model_name='release',
            name='stories',
            field=models.ManyToManyField(to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='deploymentpackage',
            name='release',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Release'),
        ),
        migrations.AddField(
            model_name='deploymentpackage',
            name='source_environment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='to_deployment_packages', to='stratosource.Branch'),
        ),
        migrations.AddField(
            model_name='deployabletranslation',
            name='pending_stories',
            field=models.ManyToManyField(related_name='stratosource_deployabletranslation_pending', to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='deployabletranslation',
            name='released_stories',
            field=models.ManyToManyField(related_name='stratosource_deployabletranslation_released', to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='deployableobject',
            name='pending_stories',
            field=models.ManyToManyField(related_name='stratosource_deployableobject_pending', to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='deployableobject',
            name='released_stories',
            field=models.ManyToManyField(related_name='stratosource_deployableobject_released', to='stratosource.Story'),
        ),
        migrations.AddField(
            model_name='delta',
            name='object',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.DeployableObject'),
        ),
        migrations.AddField(
            model_name='delta',
            name='user_change',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='stratosource.UserChange'),
        ),
        migrations.AddField(
            model_name='branch',
            name='repo',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stratosource.Repo'),
        ),

        migrations.RunPython(populate_configs),
    ]
