text: # Generated by Django 3.0.5 on 2020-04-21 14:02
  
  import core.fields
  import django.contrib.postgres.fields.jsonb
  from django.db import migrations, models
  import django.db.models.deletion
  import mas_cache.models
  
  
  class Migration(migrations.Migration):
  
  	initial = True
  
  	dependencies = [
  	]
  
  	operations = [
  		migrations.CreateModel(
  			name='Application',
  			fields=[
  				('itunes_id', models.PositiveIntegerField(primary_key=True, serialize=False)),
  			],
  		),
  		migrations.CreateModel(
  			name='AppStore',
  			fields=[
  				('country', models.CharField(max_length=2, primary_key=True, serialize=False, validators=[mas_cache.models.CountryCodeValidator])),
  			],
  		),
  		migrations.CreateModel(
  			name='Metadata',
  			fields=[
  				('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  				('source', models.URLField(max_length=4096)),
  				('timestamp', models.DateTimeField()),
  				('data', django.contrib.postgres.fields.jsonb.JSONField()),
  				('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mas_cache.Application')),
  				('store', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mas_cache.AppStore')),
  			],
  			options={
  				'unique_together': {('application', 'store', 'source', 'timestamp')},
  			},
  		),
  		migrations.CreateModel(
  			name='Genre',
  			fields=[
  				('itunes_id', models.PositiveSmallIntegerField(primary_key=True, serialize=False)),
  				('name', models.CharField(blank=True, default=None, max_length=255, null=True)),
  				('parent', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='mas_cache.Genre')),
  			],
  		),
  		migrations.CreateModel(
  			name='Chart',
  			fields=[
  				('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  				('chart_type', core.fields.IntegerChoicesField(choices_class=mas_cache.models.ChartType)),
  				('timestamp', models.DateTimeField()),
  				('genre', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='charts', to='mas_cache.Genre')),
  				('store', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='charts', to='mas_cache.AppStore')),
  			],
  			options={
  				'unique_together': {('genre', 'store', 'chart_type', 'timestamp')},
  			},
  		),
  		migrations.AddField(
  			model_name='appstore',
  			name='applications',
  			field=models.ManyToManyField(related_name='stores', through='mas_cache.Metadata', to='mas_cache.Application'),
  		),
  		migrations.CreateModel(
  			name='ChartEntry',
  			fields=[
  				('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  				('position', models.PositiveSmallIntegerField()),
  				('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mas_cache.Application')),
  				('chart', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='entries', to='mas_cache.Chart')),
  			],
  			options={
  				'unique_together': {('chart', 'position'), ('chart', 'application'), ('chart', 'application', 'position')},
  			},
  		),
  	]
  