fix migration, now really
This commit is contained in:
parent
1d1d50769b
commit
31220b4f93
2 changed files with 50 additions and 47 deletions
50
src/c3nav/mapdata/migrations/0060_access_permission_id.py
Normal file
50
src/c3nav/mapdata/migrations/0060_access_permission_id.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.7 on 2017-12-18 14:08
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import c3nav.mapdata.models.access
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mapdata', '0059_multiple_accesspermissions'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='accesspermissiontoken',
|
||||||
|
name='author',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='AccessPermissionToken',
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AccessPermissionToken',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('token', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||||
|
('valid_until',
|
||||||
|
models.DateTimeField(db_index=True, default=c3nav.mapdata.models.access.default_valid_until,
|
||||||
|
verbose_name='valid until')),
|
||||||
|
('unlimited', models.BooleanField(db_index=True, default=False, verbose_name='unlimited')),
|
||||||
|
('redeemed', models.BooleanField(db_index=True, default=False, verbose_name='redeemed')),
|
||||||
|
('can_grant', models.BooleanField(db_index=True, default=False, verbose_name='can grant')),
|
||||||
|
('data', models.BinaryField()),
|
||||||
|
('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name='created_accesspermission_tokens',
|
||||||
|
to=settings.AUTH_USER_MODEL, verbose_name='author')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='accesspermission',
|
||||||
|
name='token',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name='accesspermissions', to='mapdata.AccessPermissionToken',
|
||||||
|
verbose_name='Access permission token'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,47 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Generated by Django 1.11.7 on 2017-12-18 13:49
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
|
|
||||||
def remove_all_tokens(apps, schema_editor):
|
|
||||||
apps.get_model('mapdata', 'AccessPermissionToken').objects.all().delete()
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('mapdata', '0059_multiple_accesspermissions'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(remove_all_tokens, remove_all_tokens),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='accesspermission',
|
|
||||||
name='token',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='accesspermission',
|
|
||||||
name='id',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='accesspermissiontoken',
|
|
||||||
name='id',
|
|
||||||
field=models.AutoField(primary_key=True, serialize=False),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='accesspermissiontoken',
|
|
||||||
name='token',
|
|
||||||
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='accesspermission',
|
|
||||||
name='token',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
|
|
||||||
related_name='accesspermissions', to='mapdata.AccessPermissionToken',
|
|
||||||
verbose_name='Access permission token'),
|
|
||||||
),
|
|
||||||
]
|
|
Loading…
Add table
Add a link
Reference in a new issue