text: # Generated by Django 3.1.2 on 2020-11-16 09:51
  
  import django.db.models.deletion
  from django.db import migrations, models
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ("hours", "0005_signedauthentry"),
      ]
  
      operations = [
          migrations.CreateModel(
              name="PeriodOrigin",
              fields=[
                  (
                      "id",
                      models.AutoField(
                          auto_created=True,
                          primary_key=True,
                          serialize=False,
                          verbose_name="ID",
                      ),
                  ),
                  (
                      "origin_id",
                      models.CharField(
                          db_index=True, max_length=100, verbose_name="Origin ID"
                      ),
                  ),
                  (
                      "data_source",
                      models.ForeignKey(
                          on_delete=django.db.models.deletion.CASCADE,
                          to="hours.datasource",
                      ),
                  ),
                  (
                      "period",
                      models.ForeignKey(
                          on_delete=django.db.models.deletion.CASCADE,
                          related_name="origins",
                          to="hours.dateperiod",
                      ),
                  ),
              ],
              options={
                  "verbose_name": "Period origin",
                  "verbose_name_plural": "Period origins",
              },
          ),
          migrations.AddField(
              model_name="dateperiod",
              name="data_sources",
              field=models.ManyToManyField(
                  through="hours.PeriodOrigin", to="hours.datasource"
              ),
          ),
          migrations.AddConstraint(
              model_name="periodorigin",
              constraint=models.UniqueConstraint(
                  fields=("data_source", "origin_id"),
                  name="unique_period_identifier_per_data_source",
              ),
          ),
      ]
  