# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-05-17 20:03
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Environment',
            fields=[
                ('environment_id', models.AutoField(primary_key=True, serialize=False)),
                ('env_name', models.CharField(help_text=b'Example: dev, stage, prod.', max_length=40, verbose_name=b'Environment Name')),
                ('env_descr', models.TextField(help_text=b'Enter a longer description including use cases or important notes.', max_length=2000, verbose_name=b'Long Description')),
                ('created_dt', models.DateField(editable=False)),
                ('modified_dt', models.DateField(editable=False)),
            ],
            options={
                'ordering': ['env_name'],
                'db_table': 'ele_environment',
                'verbose_name': 'System Environment',
            },
        ),
        migrations.CreateModel(
            name='Herd',
            fields=[
                ('herd_id', models.AutoField(primary_key=True, serialize=False)),
                ('base_name', models.CharField(help_text=b'Used to identify this herd, and for CLI tools like pg_ctlcluster and the underlying OS.', max_length=40, verbose_name=b'Instance')),
                ('herd_name', models.CharField(help_text=b'Logical name for the herd, so multiple similar herds can occupy the same environment.', max_length=40, verbose_name=b'Herd Name')),
                ('herd_descr', models.TextField(help_text=b'Enter important details, notes, or caveats here.', max_length=2000, verbose_name=b'Long Description')),
                ('db_port', models.IntegerField(default=5432, help_text=b'Connection port for hosting this herd. Used for all hosts.', verbose_name=b'Port')),
                ('pgdata', models.CharField(help_text=b'Full path to root data directory. Used for all hosts.', max_length=100, verbose_name=b'Data Root')),
                ('vhost', models.CharField(help_text=b'Virtual host name to identify primary herd member.', max_length=40, verbose_name=b'Virtual Host')),
                ('created_dt', models.DateField(editable=False)),
                ('modified_dt', models.DateField(editable=False)),
                ('environment', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='haas.Environment')),
            ],
            options={
                'ordering': ['herd_name'],
                'db_table': 'ele_herd',
                'verbose_name': 'Herd',
            },
        ),
        migrations.CreateModel(
            name='Instance',
            fields=[
                ('instance_id', models.AutoField(primary_key=True, serialize=False)),
                ('version', models.CharField(blank=True, editable=False, max_length=10, verbose_name=b'PG Version')),
                ('local_pgdata', models.CharField(blank=True, help_text=b'Full path to root data directory if different from herd default. May be necessary for legacy systems.', max_length=100, verbose_name=b'Data Root Override')),
                ('xlog_pos', models.BigIntegerField(editable=False, null=True, verbose_name=b'Current XLOG Position')),
                ('is_online', models.BooleanField(default=False, editable=False, verbose_name=b'Online')),
                ('created_dt', models.DateField(editable=False)),
                ('modified_dt', models.DateField(editable=False)),
            ],
            options={
                'ordering': ['herd'],
                'db_table': 'ele_instance',
                'verbose_name': 'Instance',
            },
        ),
        migrations.CreateModel(
            name='Server',
            fields=[
                ('server_id', models.AutoField(primary_key=True, serialize=False)),
                ('hostname', models.CharField(max_length=40, verbose_name=b'Host Name')),
                ('created_dt', models.DateField(editable=False)),
                ('modified_dt', models.DateField(editable=False)),
                ('environment', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='haas.Environment')),
            ],
            options={
                'ordering': ['hostname'],
                'db_table': 'ele_server',
                'verbose_name': 'Server',
            },
        ),
        migrations.CreateModel(
            name='DisasterRecovery',
            fields=[
                ('instance', models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='haas.Instance')),
                ('mb_lag', models.DecimalField(decimal_places=2, max_digits=5, null=True, verbose_name=b'Sync Delay (MB)')),
                ('vhost', models.CharField(help_text=b'Virtual host name to identify primary herd member.', max_length=40, verbose_name=b'Virtual Host')),
            ],
            options={
                'verbose_name': 'Disaster Recovery Pair',
                'db_table': 'v_dr_pairs',
                'managed': False,
            },
        ),
        migrations.AddField(
            model_name='instance',
            name='herd',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='haas.Herd'),
        ),
        migrations.AddField(
            model_name='instance',
            name='master',
            field=models.ForeignKey(blank=True, editable=False, help_text=b'If this is a replica, the upstream data source.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='haas.Instance'),
        ),
        migrations.AddField(
            model_name='instance',
            name='server',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='haas.Server'),
        ),
    ]
