|
| 1 | +from django.db import migrations, models |
| 2 | +import django.db.models.deletion |
| 3 | + |
| 4 | + |
| 5 | +class Migration(migrations.Migration): |
| 6 | + |
| 7 | + dependencies = [ |
| 8 | + ('accounts', '0141_notification_text_default'), |
| 9 | + ] |
| 10 | + |
| 11 | + operations = [ |
| 12 | + # UserGroup.type |
| 13 | + migrations.AddField( |
| 14 | + model_name='usergroup', |
| 15 | + name='type', |
| 16 | + field=models.CharField( |
| 17 | + choices=[ |
| 18 | + ('regular', 'Regular'), |
| 19 | + ('personal', 'Personal'), |
| 20 | + ], |
| 21 | + default='regular', |
| 22 | + max_length=20, |
| 23 | + ), |
| 24 | + ), |
| 25 | + # UserVacation model (normalized vacation data) |
| 26 | + migrations.CreateModel( |
| 27 | + name='UserVacation', |
| 28 | + fields=[ |
| 29 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
| 30 | + ('is_deleted', models.BooleanField(default=False)), |
| 31 | + ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.account')), |
| 32 | + ('start_date', models.DateField(blank=True, null=True)), |
| 33 | + ('end_date', models.DateField(blank=True, null=True)), |
| 34 | + ('absence_status', models.CharField(choices=[('active', 'Active'), ('vacation', 'On vacation'), ('sick_leave', 'Sick leave')], default='vacation', max_length=20)), |
| 35 | + ('substitute_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='vacation_owners', to='accounts.usergroup')), |
| 36 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vacations', to='accounts.user')), |
| 37 | + ], |
| 38 | + ), |
| 39 | + migrations.AddConstraint( |
| 40 | + model_name='uservacation', |
| 41 | + constraint=models.UniqueConstraint( |
| 42 | + condition=models.Q(is_deleted=False), |
| 43 | + fields=['user'], |
| 44 | + name='unique_active_vacation_per_user', |
| 45 | + ), |
| 46 | + ), |
| 47 | + ] |
| 48 | + |
0 commit comments