# Generated by Django 2.2.3 on 2019-12-02 17:23

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

import music_publisher.validators


class Migration(migrations.Migration):
    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ACKImport',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('filename', models.CharField(editable=False, max_length=60)),
                ('society_code',
                 models.CharField(editable=False, max_length=3)),
                ('society_name',
                 models.CharField(editable=False, max_length=45)),
                ('date', models.DateField(editable=False)),
                ('report', models.TextField(editable=False)),
            ],
            options={
                'verbose_name': 'CWR ACK Import',
                'ordering': ('-date', '-id'),
            },
        ),
        migrations.CreateModel(
            name='Artist',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(blank=True, max_length=30,
                                                validators=[
                                                    music_publisher.validators.CWRFieldValidator(
                                                        'artist_first_name')])),
                ('last_name', models.CharField(db_index=True, max_length=45,
                                               validators=[
                                                   music_publisher.validators.CWRFieldValidator(
                                                       'artist_last_name')])),
                ('isni', models.CharField(blank=True, max_length=16, null=True,
                                          unique=True, validators=[
                        music_publisher.validators.CWRFieldValidator('isni')],
                                          verbose_name='ISNI')),
            ],
            options={
                'verbose_name': 'Performing Artist',
                'verbose_name_plural': '  Performing Artists',
                'ordering': ('last_name', 'first_name', '-id'),
            },
        ),
        migrations.CreateModel(
            name='ArtistInWork',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('artist',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='music_publisher.Artist')),
            ],
            options={
                'verbose_name': 'Performing artist',
                'verbose_name_plural': 'Performing artists (not mentioned in '
                                       'recordings section)',
                'ordering': ('artist__last_name', 'artist__first_name'),
            },
        ),
        migrations.CreateModel(
            name='Label',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=60, unique=True,
                                          validators=[
                                              music_publisher.validators.CWRFieldValidator(
                                                  'label')])),
            ],
            options={
                'verbose_name_plural': '  Music Labels',
                'ordering': ('name',),
            },
        ),
        migrations.CreateModel(
            name='Library',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=60, unique=True,
                                          validators=[
                                              music_publisher.validators.CWRFieldValidator(
                                                  'library')])),
            ],
            options={
                'verbose_name_plural': '  Music Libraries',
                'ordering': ('name',),
            },
        ),
        migrations.CreateModel(
            name='Recording',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('recording_title', models.CharField(blank=True, max_length=60,
                                                     validators=[
                                                         music_publisher.validators.CWRFieldValidator(
                                                             'work_title')])),
                ('recording_title_suffix', models.BooleanField(default=False,
                                                               help_text='A '
                                                                         'suffix to the WORK title.')),
                ('version_title', models.CharField(blank=True, max_length=60,
                                                   validators=[
                                                       music_publisher.validators.CWRFieldValidator(
                                                           'work_title')])),
                ('version_title_suffix', models.BooleanField(default=False,
                                                             help_text='A '
                                                                       'suffix to the RECORDING title.')),
                ('release_date', models.DateField(blank=True, null=True)),
                ('duration', models.DurationField(blank=True, null=True)),
                ('isrc', models.CharField(blank=True, max_length=15, null=True,
                                          unique=True, validators=[
                        music_publisher.validators.CWRFieldValidator('isrc')],
                                          verbose_name='ISRC')),
                ('artist', models.ForeignKey(blank=True, null=True,
                                             on_delete=django.db.models.deletion.PROTECT,
                                             to='music_publisher.Artist',
                                             verbose_name='Recording Artist')),
                ('record_label', models.ForeignKey(blank=True, null=True,
                                                   on_delete=django.db.models.deletion.PROTECT,
                                                   to='music_publisher.Label',
                                                   verbose_name='Record '
                                                                'label')),
            ],
            options={
                'verbose_name_plural': '  Recordings',
                'ordering': ('-id',),
            },
        ),
        migrations.CreateModel(
            name='Release',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('cd_identifier',
                 models.CharField(blank=True, max_length=15, null=True,
                                  unique=True, validators=[
                         music_publisher.validators.CWRFieldValidator(
                             'cd_identifier')], verbose_name='CD identifier')),
                ('release_date', models.DateField(blank=True, null=True)),
                ('release_title',
                 models.CharField(blank=True, max_length=60, null=True,
                                  unique=True, validators=[
                         music_publisher.validators.CWRFieldValidator(
                             'release_title')],
                                  verbose_name='Release (album) title ')),
                ('ean', models.CharField(blank=True, max_length=13, null=True,
                                         unique=True, validators=[
                        music_publisher.validators.CWRFieldValidator('ean')],
                                         verbose_name='Release (album) EAN')),
                ('library', models.ForeignKey(blank=True, null=True,
                                              on_delete=django.db.models.deletion.PROTECT,
                                              to='music_publisher.Library')),
            ],
            options={
                'ordering': ('release_title', 'cd_identifier', '-id'),
            },
        ),
        migrations.CreateModel(
            name='Work',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('title', models.CharField(db_index=True, max_length=60,
                                           validators=[
                                               music_publisher.validators.CWRFieldValidator(
                                                   'work_title')])),
                ('iswc', models.CharField(blank=True, max_length=15, null=True,
                                          unique=True, validators=[
                        music_publisher.validators.CWRFieldValidator('iswc')],
                                          verbose_name='ISWC')),
                ('original_title', models.CharField(blank=True, db_index=True,
                                                    help_text='Use only for '
                                                              'modification '
                                                              'of existing '
                                                              'works.',
                                                    max_length=60, validators=[
                        music_publisher.validators.CWRFieldValidator(
                            'work_title')])),
                ('last_change', models.DateTimeField(editable=False, null=True,
                                                     verbose_name='Last '
                                                                  'Edited')),
                ('artists',
                 models.ManyToManyField(through='music_publisher.ArtistInWork',
                                        to='music_publisher.Artist')),
            ],
            options={
                'verbose_name': '    Musical Work',
                'ordering': ('-id',),
            },
        ),
        migrations.CreateModel(
            name='Writer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(blank=True, max_length=30,
                                                validators=[
                                                    music_publisher.validators.CWRFieldValidator(
                                                        'artist_first_name')])),
                ('last_name', models.CharField(db_index=True, max_length=45,
                                               validators=[
                                                   music_publisher.validators.CWRFieldValidator(
                                                       'artist_last_name')])),
                ('ipi_name',
                 models.CharField(blank=True, max_length=11, null=True,
                                  unique=True, validators=[
                         music_publisher.validators.CWRFieldValidator(
                             'writer_ipi_name')], verbose_name='IPI Name #')),
                ('ipi_base',
                 models.CharField(blank=True, max_length=15, null=True,
                                  validators=[
                                      music_publisher.validators.CWRFieldValidator(
                                          'writer_ipi_base')],
                                  verbose_name='IPI Base #')),
                ('pr_society', models.CharField(blank=True, choices=[
                    ('55', 'SABAM, Belgium'), ('101', 'SOCAN, Canada'),
                    ('88', 'CMRRA, Canada'), ('40', 'KODA, Denmark'),
                    ('89', 'TEOSTO, Finland'), ('58', 'SACEM, France'),
                    ('35', 'GEMA, Germany'), ('74', 'SIAE, Italy'),
                    ('23', 'BUMA, Netherlands'), ('78', 'STEMRA, Netherlands'),
                    ('90', 'TONO, Norway'), ('79', 'STIM, Sweden'),
                    ('52', 'PRS, United Kingdom'),
                    ('44', 'MCPS, United Kingdom'),
                    ('10', 'ASCAP, United States'),
                    ('21', 'BMI, United States'),
                    ('71', 'SESAC Inc., United States'),
                    ('34', 'HFA, United States'),
                    ('319', 'ICE Services, Administrative Agency'),
                    ('707', 'Musicmark, Administrative Agency')], max_length=3,
                                                null=True, validators=[
                        music_publisher.validators.CWRFieldValidator(
                            'writer_pr_society')],
                                                verbose_name='Performance '
                                                             'rights '
                                                             'society')),
                ('mr_society', models.CharField(blank=True, choices=[
                    ('55', 'SABAM, Belgium'), ('101', 'SOCAN, Canada'),
                    ('88', 'CMRRA, Canada'), ('40', 'KODA, Denmark'),
                    ('89', 'TEOSTO, Finland'), ('58', 'SACEM, France'),
                    ('35', 'GEMA, Germany'), ('74', 'SIAE, Italy'),
                    ('23', 'BUMA, Netherlands'), ('78', 'STEMRA, Netherlands'),
                    ('90', 'TONO, Norway'), ('79', 'STIM, Sweden'),
                    ('52', 'PRS, United Kingdom'),
                    ('44', 'MCPS, United Kingdom'),
                    ('10', 'ASCAP, United States'),
                    ('21', 'BMI, United States'),
                    ('71', 'SESAC Inc., United States'),
                    ('34', 'HFA, United States'),
                    ('319', 'ICE Services, Administrative Agency'),
                    ('707', 'Musicmark, Administrative Agency')], max_length=3,
                                                null=True, validators=[
                        music_publisher.validators.CWRFieldValidator(
                            'writer_pr_society')],
                                                verbose_name='Mechanical '
                                                             'rights '
                                                             'society')),
                ('sr_society', models.CharField(blank=True, choices=[
                    ('55', 'SABAM, Belgium'), ('101', 'SOCAN, Canada'),
                    ('88', 'CMRRA, Canada'), ('40', 'KODA, Denmark'),
                    ('89', 'TEOSTO, Finland'), ('58', 'SACEM, France'),
                    ('35', 'GEMA, Germany'), ('74', 'SIAE, Italy'),
                    ('23', 'BUMA, Netherlands'), ('78', 'STEMRA, Netherlands'),
                    ('90', 'TONO, Norway'), ('79', 'STIM, Sweden'),
                    ('52', 'PRS, United Kingdom'),
                    ('44', 'MCPS, United Kingdom'),
                    ('10', 'ASCAP, United States'),
                    ('21', 'BMI, United States'),
                    ('71', 'SESAC Inc., United States'),
                    ('34', 'HFA, United States'),
                    ('319', 'ICE Services, Administrative Agency'),
                    ('707', 'Musicmark, Administrative Agency')], max_length=3,
                                                null=True, validators=[
                        music_publisher.validators.CWRFieldValidator(
                            'writer_pr_society')],
                                                verbose_name='Synchronization rights society')),
                ('saan', models.CharField(blank=True,
                                          help_text='Use this field for '
                                                    'general agreements only.',
                                          max_length=14, null=True,
                                          unique=True, validators=[
                        music_publisher.validators.CWRFieldValidator('saan')],
                                          verbose_name='Society-assigned '
                                                       'agreement number')),
                ('_can_be_controlled',
                 models.BooleanField(default=False, editable=False)),
                ('generally_controlled', models.BooleanField(default=False,
                                                             verbose_name='General agreement')),
                ('publisher_fee',
                 models.DecimalField(blank=True, decimal_places=2,
                                     help_text='Percentage of royalties kept '
                                               'by the publisher',
                                     max_digits=5, null=True, validators=[
                         django.core.validators.MinValueValidator(0),
                         django.core.validators.MaxValueValidator(100)])),
            ],
            options={
                'verbose_name_plural': '  Writers',
                'ordering': ('last_name', 'first_name', 'ipi_name', '-id'),
            },
        ),
        migrations.CreateModel(
            name='WriterInWork',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('saan', models.CharField(blank=True,
                                          help_text='Use this field for '
                                                    'specific agreements '
                                                    'only.',
                                          max_length=14, null=True,
                                          validators=[
                                              music_publisher.validators.CWRFieldValidator(
                                                  'saan')],
                                          verbose_name='Society-assigned '
                                                       'agreement number')),
                ('controlled', models.BooleanField(default=False)),
                ('relative_share',
                 models.DecimalField(decimal_places=2, max_digits=5)),
                ('capacity', models.CharField(blank=True, choices=[
                    ('CA', 'Composer&Lyricist'), ('C ', 'Composer'),
                    ('A ', 'Lyricist'), ('AR', 'Arranger'), ('AD', 'Adaptor'),
                    ('TR', 'Translator')], max_length=2)),
                ('publisher_fee',
                 models.DecimalField(blank=True, decimal_places=2,
                                     help_text='Percentage of royalties kept '
                                               'by the publisher',
                                     max_digits=5, null=True, validators=[
                         django.core.validators.MinValueValidator(0),
                         django.core.validators.MaxValueValidator(100)])),
                ('work',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='music_publisher.Work')),
                ('writer', models.ForeignKey(blank=True, null=True,
                                             on_delete=django.db.models.deletion.PROTECT,
                                             to='music_publisher.Writer')),
            ],
            options={
                'verbose_name_plural': 'Writers in Work',
                'ordering': (
                '-controlled', 'writer__last_name', 'writer__first_name',
                '-id'),
                'unique_together': {('work', 'writer', 'controlled')},
            },
        ),
        migrations.CreateModel(
            name='WorkAcknowledgement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('society_code', models.CharField(
                    choices=[('55', 'SABAM, Belgium'),
                             ('101', 'SOCAN, Canada'), ('88', 'CMRRA, Canada'),
                             ('40', 'KODA, Denmark'),
                             ('89', 'TEOSTO, Finland'),
                             ('58', 'SACEM, France'), ('35', 'GEMA, Germany'),
                             ('74', 'SIAE, Italy'),
                             ('23', 'BUMA, Netherlands'),
                             ('78', 'STEMRA, Netherlands'),
                             ('90', 'TONO, Norway'), ('79', 'STIM, Sweden'),
                             ('52', 'PRS, United Kingdom'),
                             ('44', 'MCPS, United Kingdom'),
                             ('10', 'ASCAP, United States'),
                             ('21', 'BMI, United States'),
                             ('71', 'SESAC Inc., United States'),
                             ('34', 'HFA, United States'),
                             ('319', 'ICE Services, Administrative Agency'),
                             ('707', 'Musicmark, Administrative Agency')],
                    max_length=3, verbose_name='Society')),
                ('date', models.DateField()),
                ('status', models.CharField(
                    choices=[('CO', 'Conflict'), ('DU', 'Duplicate'),
                             ('RA', 'Transaction Accepted'),
                             ('AS', 'Registration Accepted'),
                             ('AC', 'Registration Accepted with Changes'), (
                             'SR',
                             'Registration Accepted - Ready for Payment'), (
                             'CR',
                             'Registration Accepted with Changes - Ready for Payment'),
                             ('RJ', 'Rejected'), ('NP', 'No Participation'),
                             ('RC', 'Claim rejected'),
                             ('NA', 'Rejected - No Society Agreement Number'),
                             ('WA',
                              'Rejected - Wrong Society Agreement Number')],
                    max_length=2)),
                (
                'remote_work_id', models.CharField(blank=True, max_length=20)),
                ('work',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='music_publisher.Work')),
            ],
            options={
                'verbose_name': 'Registration Acknowledgement',
                'ordering': ('-date', '-id'),
            },
        ),
        migrations.AddField(
            model_name='work',
            name='writers',
            field=models.ManyToManyField(
                through='music_publisher.WriterInWork',
                to='music_publisher.Writer'),
        ),
        migrations.CreateModel(
            name='Track',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('cut_number',
                 models.PositiveSmallIntegerField(blank=True, null=True,
                                                  validators=[
                                                      django.core.validators.MinValueValidator(
                                                          1),
                                                      django.core.validators.MaxValueValidator(
                                                          9999)])),
                ('recording',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   related_name='tracks',
                                   to='music_publisher.Recording')),
                ('release',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   related_name='tracks',
                                   to='music_publisher.Release')),
            ],
            options={
                'ordering': ('release', 'cut_number'),
                'unique_together': {('release', 'cut_number'),
                                    ('recording', 'release')},
            },
        ),
        migrations.AddField(
            model_name='release',
            name='recordings',
            field=models.ManyToManyField(through='music_publisher.Track',
                                         to='music_publisher.Recording'),
        ),
        migrations.AddField(
            model_name='release',
            name='release_label',
            field=models.ForeignKey(blank=True, null=True,
                                    on_delete=django.db.models.deletion.PROTECT,
                                    to='music_publisher.Label',
                                    verbose_name='Release (album) label'),
        ),
        migrations.AddField(
            model_name='recording',
            name='releases',
            field=models.ManyToManyField(through='music_publisher.Track',
                                         to='music_publisher.Release'),
        ),
        migrations.AddField(
            model_name='recording',
            name='work',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='recordings', to='music_publisher.Work'),
        ),
        migrations.CreateModel(
            name='CWRExport',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('nwr_rev', models.CharField(
                    choices=[('NWR', 'CWR 2.1: New work registrations'),
                             ('REV', 'CWR 2.1: Revisions of registered works'),
                             ('WRK',
                              'CWR 3.0: Work registration (experimental)'),
                             ('ISR', 'CWR 3.0: ISWC request (experimental)')],
                    db_index=True, default='NWR', max_length=3,
                    verbose_name='CWR version/type')),
                ('cwr', models.TextField(blank=True, editable=False)),
                ('year',
                 models.CharField(blank=True, db_index=True, editable=False,
                                  max_length=2)),
                ('num_in_year', models.PositiveSmallIntegerField(default=0)),
                ('description', models.CharField(blank=True, max_length=60,
                                                 verbose_name='Internal Note')),
                ('works', models.ManyToManyField(related_name='cwr_exports',
                                                 to='music_publisher.Work')),
            ],
            options={
                'verbose_name': 'CWR Export',
                'verbose_name_plural': ' CWR Exports',
                'ordering': ('-id',),
            },
        ),
        migrations.AddField(
            model_name='artistinwork',
            name='work',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='music_publisher.Work'),
        ),
        migrations.CreateModel(
            name='CommercialRelease',
            fields=[
            ],
            options={
                'verbose_name_plural': '  Commercial Releases',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('music_publisher.release',),
        ),
        migrations.CreateModel(
            name='LibraryRelease',
            fields=[
            ],
            options={
                'verbose_name_plural': '  Library Releases',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('music_publisher.release',),
        ),
        migrations.AddField(
            model_name='work',
            name='library_release',
            field=models.ForeignKey(blank=True, null=True,
                                    on_delete=django.db.models.deletion.PROTECT,
                                    related_name='works',
                                    to='music_publisher.LibraryRelease',
                                    verbose_name='Library Release'),
        ),
        migrations.AlterUniqueTogether(
            name='artistinwork',
            unique_together={('work', 'artist')},
        ),
        migrations.CreateModel(
            name='AlternateTitle',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True,
                                        serialize=False, verbose_name='ID')),
                ('title', models.CharField(db_index=True, max_length=60,
                                           validators=[
                                               music_publisher.validators.CWRFieldValidator(
                                                   'work_title')])),
                ('suffix', models.BooleanField(default=False,
                                               help_text='Select if this title is only a suffix to the main title.')),
                ('work',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='music_publisher.Work')),
            ],
            options={
                'ordering': ('-suffix', 'title'),
                'unique_together': {('work', 'title')},
            },
        ),
    ]
