Fixed squashed migrations

This commit is contained in:
Adolfo Gómez García 2022-02-06 03:58:54 +01:00
parent 0355ef9591
commit c4a886c28d
6 changed files with 29 additions and 164 deletions

View File

@ -5,14 +5,35 @@ from django.db import migrations, models
import django.db.models.deletion
import uds.models.util
MOVEABLES = (
'Site name',
'Site copyright info',
'Site copyright link',
'Site Logo name'
)
OLD_SECTION = 'UDS'
NEW_SECTION = 'Custom'
def move(apps, old_section: str, new_section: str) -> None:
model = apps.get_model('uds', 'Config')
# Ensure NEW section values does not exists
model.objects.filter(section=new_section, key__in=MOVEABLES).delete()
for v in model.objects.filter(section=old_section, key__in=MOVEABLES):
v.section = new_section
v.save()
def updateConfig(apps, schema_editor) -> None:
move(apps, OLD_SECTION, NEW_SECTION)
def reverseConfig(apps, schema_editor) -> None:
move(apps, NEW_SECTION, OLD_SECTION)
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Authenticator',
@ -1133,4 +1154,8 @@ class Migration(migrations.Migration):
model_name='tunneltoken',
constraint=models.UniqueConstraint(fields=('ip', 'hostname'), name='tt_ip_hostname'),
),
migrations.RunPython(
updateConfig,
reverseConfig
)
]

View File

@ -1,29 +0,0 @@
# Generated by Django 3.1.2 on 2020-11-11 13:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('uds', '0026_auto_20180302_0525_squashed_0038_auto_20200505_config'),
]
operations = [
migrations.RemoveField(
model_name='metapool',
name='accessCalendars',
),
migrations.RemoveField(
model_name='metapool',
name='pools',
),
migrations.RemoveField(
model_name='servicepool',
name='accessCalendars',
),
migrations.RemoveField(
model_name='servicepool',
name='actionsCalendars',
),
]

View File

@ -1,23 +0,0 @@
# Generated by Django 3.2 on 2021-04-22 13:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('uds', '0039_auto_20201111_1329'),
]
operations = [
migrations.AddField(
model_name='metapool',
name='transport_grouping',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='transport',
name='label',
field=models.CharField(db_index=True, default='', max_length=32),
),
]

View File

@ -1,79 +0,0 @@
# Generated by Django 3.2.4 on 2021-06-24 12:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('uds', '0040_auto_20210422_1340'),
]
operations = [
migrations.AlterUniqueTogether(
name='config',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='service',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='uniqueid',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='userserviceproperty',
unique_together=set(),
),
migrations.AlterIndexTogether(
name='userservice',
index_together=set(),
),
migrations.AddIndex(
model_name='statscounters',
index=models.Index(fields=['owner_type', 'stamp'], name='uds_stats_c_owner_t_db894d_idx'),
),
migrations.AddIndex(
model_name='statscounters',
index=models.Index(fields=['owner_type', 'counter_type', 'stamp'], name='uds_stats_c_owner_t_a195c1_idx'),
),
migrations.AddIndex(
model_name='userservice',
index=models.Index(fields=['deployed_service', 'cache_level', 'state'], name='uds__user_s_deploye_a38d25_idx'),
),
migrations.AddConstraint(
model_name='config',
constraint=models.UniqueConstraint(fields=('section', 'key'), name='u_cfg_section_key'),
),
migrations.AddConstraint(
model_name='service',
constraint=models.UniqueConstraint(fields=('provider', 'name'), name='u_srv_provider_name'),
),
migrations.AddConstraint(
model_name='uniqueid',
constraint=models.UniqueConstraint(fields=('basename', 'seq'), name='u_uid_base_seq'),
),
migrations.AddConstraint(
model_name='userserviceproperty',
constraint=models.UniqueConstraint(fields=('name', 'user_service'), name='u_uprop_name_userservice'),
),
# Add user and groups constrains before removing old unique_together
migrations.AddConstraint(
model_name='user',
constraint=models.UniqueConstraint(fields=('manager', 'name'), name='u_usr_manager_name'),
),
migrations.AddConstraint(
model_name='group',
constraint=models.UniqueConstraint(fields=('manager', 'name'), name='u_grp_manager_name'),
),
# These must be removed after created contrains, because they are used in foreign keys
migrations.AlterUniqueTogether(
name='user',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='group',
unique_together=set(),
),
]

View File

@ -1,29 +0,0 @@
# Generated by Django 3.2.4 on 2021-06-28 15:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('uds', '0041_auto_20210624_1233'),
]
operations = [
migrations.CreateModel(
name='TunnelToken',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=128)),
('ip_from', models.CharField(max_length=16)),
('ip', models.CharField(max_length=16)),
('hostname', models.CharField(max_length=128)),
('token', models.CharField(db_index=True, max_length=48, unique=True)),
('stamp', models.DateTimeField()),
],
),
migrations.AddConstraint(
model_name='tunneltoken',
constraint=models.UniqueConstraint(fields=('ip', 'hostname'), name='tt_ip_hostname'),
),
]

View File

@ -35,7 +35,7 @@ def clean_config(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('uds', '0042_auto_20210628_1533'),
('uds', '0001_squashed_0042_auto_20210628_1533'),
]
operations = [