<reponame>julianespinel/fund<filename>funds/migrations/0001_initial.py
# Generated by Django 3.2 on 2021-06-03 03:34

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Fund',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128, unique=True)),
                ('added_usd', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('market_value', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'funds',
            },
        ),
        migrations.CreateModel(
            name='HistoricalPrice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField()),
                ('symbol', models.CharField(max_length=128)),
                ('closing_price', models.DecimalField(decimal_places=7, max_digits=19)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'historical_prices',
            },
        ),
        migrations.CreateModel(
            name='Position',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('symbol', models.CharField(max_length=128)),
                ('units', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fund', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='funds.fund')),
            ],
            options={
                'db_table': 'portfolio',
            },
        ),
        migrations.CreateModel(
            name='PortfolioSnapshot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField()),
                ('positions', models.JSONField()),
                ('market_price', models.DecimalField(decimal_places=7, max_digits=19, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fund', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='funds.fund')),
            ],
            options={
                'db_table': 'portfolio_snapshots',
            },
        ),
        migrations.CreateModel(
            name='Operation',
            fields=[
                ('id', models.IntegerField(primary_key=True, serialize=False)),
                ('date', models.DateTimeField()),
                ('pair', models.CharField(max_length=128)),
                ('type', models.CharField(max_length=128)),
                ('price', models.DecimalField(decimal_places=7, max_digits=19)),
                ('units', models.DecimalField(decimal_places=7, max_digits=19)),
                ('total', models.DecimalField(decimal_places=7, max_digits=19)),
                ('fee', models.DecimalField(decimal_places=7, max_digits=19)),
                ('fee_coin', models.CharField(max_length=128)),
                ('owner', models.CharField(max_length=128)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fund', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='funds.fund')),
            ],
            options={
                'db_table': 'operations',
            },
        ),
        migrations.CreateModel(
            name='InvestorsSnapshot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField()),
                ('investors', models.JSONField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fund', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='funds.fund')),
            ],
            options={
                'db_table': 'investors_snapshots',
            },
        ),
        migrations.CreateModel(
            name='Investor',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128)),
                ('added_usd', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('market_value', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('ownership_percentage', models.DecimalField(decimal_places=7, default=0, max_digits=19)),
                ('is_manager', models.BooleanField(default=False)),
                ('joined_at', models.DateTimeField(auto_now_add=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fund', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='funds.fund')),
            ],
            options={
                'db_table': 'investors',
            },
        ),
        migrations.AddIndex(
            model_name='historicalprice',
            index=models.Index(fields=['date'], name='historical__date_5d9f42_idx'),
        ),
        migrations.AddIndex(
            model_name='historicalprice',
            index=models.Index(fields=['symbol'], name='historical__symbol_9ae9f4_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='historicalprice',
            unique_together={('date', 'symbol')},
        ),
        migrations.AlterUniqueTogether(
            name='position',
            unique_together={('symbol', 'fund')},
        ),
        migrations.AddIndex(
            model_name='portfoliosnapshot',
            index=models.Index(fields=['date'], name='portfolio_s_date_3fe8e1_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='portfoliosnapshot',
            unique_together={('date', 'fund')},
        ),
        migrations.AddIndex(
            model_name='operation',
            index=models.Index(fields=['date'], name='operations_date_0dd556_idx'),
        ),
        migrations.AddIndex(
            model_name='operation',
            index=models.Index(fields=['pair'], name='operations_pair_ba8a98_idx'),
        ),
        migrations.AddIndex(
            model_name='operation',
            index=models.Index(fields=['fund'], name='operations_fund_id_b5cbcd_idx'),
        ),
        migrations.AddIndex(
            model_name='investorssnapshot',
            index=models.Index(fields=['date'], name='investors_s_date_9258ce_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='investorssnapshot',
            unique_together={('date', 'fund')},
        ),
        migrations.AlterUniqueTogether(
            name='investor',
            unique_together={('name', 'fund')},
        ),
    ]
