Attempt to fix migrations

This commit is contained in:
Mark Veidemanis 2023-02-24 07:20:31 +00:00
parent fb5521c9f7
commit 86ace02de8
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 2 additions and 57 deletions

View File

@ -33,11 +33,6 @@ class Migration(migrations.Migration):
model_name='user',
name='plans',
),
migrations.AlterField(
model_name='user',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True),
),
migrations.DeleteModel(
name='Plan',
),

View File

@ -1,50 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
from django.db import migrations, models
def fill_mymodel_uuid(apps, schema_editor):
db_alias = schema_editor.connection.alias
MyModel = apps.get_model('core', 'User')
for obj in MyModel.objects.using(db_alias).all():
obj.uuid = uuid.uuid4()
obj.save()
class Migration(migrations.Migration):
""" Change model with integer pk to UUID pk. This migration presumes there
are no db constraints (foreign keys) to this table.
"""
dependencies = [
('core', '0074_remove_session_plan_remove_session_user_and_more'),
]
operations = [
migrations.AddField(
model_name='user',
name='uuid',
field=models.UUIDField(null=True),
),
migrations.RunPython(fill_mymodel_uuid, migrations.RunPython.noop),
migrations.AlterField(
model_name='user',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, serialize=False, editable=False, unique=True),
),
migrations.RemoveField('User', 'id'),
migrations.RenameField(
model_name='user',
old_name='uuid',
new_name='id'
),
migrations.AlterField(
model_name='user',
name='id',
field=models.UUIDField(primary_key=True, default=uuid.uuid4, serialize=False, editable=False, unique=True),
),
]

View File

@ -93,8 +93,8 @@ ADJUST_CLOSE_NOTIFY_CHOICES = (
class User(AbstractUser):
# Stripe customer ID
id = models.UUIDField(
default=uuid.uuid4, primary_key=True, editable=False, unique=True
unique_id = models.UUIDField(
default=uuid.uuid4,
)
# stripe_id = models.CharField(max_length=255, null=True, blank=True)
billing_provider_id = models.CharField(max_length=255, null=True, blank=True)