Skip to content

Commit

Permalink
Convert CharField to TextField.
Browse files Browse the repository at this point in the history
closes pulp#2742
  • Loading branch information
ipanova authored and bmbouter committed Jun 1, 2022
1 parent f6c8ec7 commit 18d9f70
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES/plugin_api/2742.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Converted ``CharField`` to ``TextField``.
79 changes: 79 additions & 0 deletions pulpcore/app/migrations/0090_char_to_text_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Generated by Django 3.2.13 on 2022-06-01 11:52

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0089_alter_contentredirectcontentguard_options'),
]

operations = [
migrations.AlterField(
model_name='accesspolicy',
name='viewset_name',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='filesystemexporter',
name='method',
field=models.TextField(choices=[('write', 'Export by writing'), ('hardlink', 'Export by hardlinking'), ('symlink', 'Export by symlinking')], default='write'),
),
migrations.AlterField(
model_name='groupprogressreport',
name='code',
field=models.TextField(),
),
migrations.AlterField(
model_name='grouprole',
name='object_id',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='label',
name='key',
field=models.TextField(db_index=True),
),
migrations.AlterField(
model_name='progressreport',
name='code',
field=models.TextField(),
),
migrations.AlterField(
model_name='repositoryversioncontentdetails',
name='count_type',
field=models.TextField(choices=[('A', 'added'), ('P', 'present'), ('R', 'removed')]),
),
migrations.AlterField(
model_name='role',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='task',
name='logging_cid',
field=models.TextField(db_index=True, default=''),
),
migrations.AlterField(
model_name='task',
name='reserved_resources_record',
field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), null=True, size=None),
),
migrations.AlterField(
model_name='taskschedule',
name='name',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='taskschedule',
name='task_name',
field=models.TextField(),
),
migrations.AlterField(
model_name='userrole',
name='object_id',
field=models.TextField(null=True),
),
]
4 changes: 2 additions & 2 deletions pulpcore/app/models/access_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AccessPolicy(BaseModel):
for newly created objects. This is a nullable field due to not all endpoints creating
objects.
statements (models.JSONField): A list of ``drf-access-policy`` statements.
viewset_name (models.CharField): The name of the viewset this instance controls
viewset_name (models.TextField): The name of the viewset this instance controls
authorization for.
customized (BooleanField): False if the AccessPolicy has been user-modified. True otherwise.
Defaults to False.
Expand All @@ -36,7 +36,7 @@ class AccessPolicy(BaseModel):

creation_hooks = models.JSONField(null=True)
statements = models.JSONField()
viewset_name = models.CharField(max_length=128, unique=True)
viewset_name = models.TextField(unique=True)
customized = models.BooleanField(default=False)
queryset_scoping = models.JSONField(null=True)

Expand Down
4 changes: 2 additions & 2 deletions pulpcore/app/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Label(LifecycleModel):
Fields:
pulp_id (models.UUIDField): Primary key identifier
object_id (models.UUIDField): Resource id
key (models.CharField): Key of the label
key (models.TextField): Key of the label
value (models.TextField): Value of the label
Relations:
Expand All @@ -28,7 +28,7 @@ class Label(LifecycleModel):
pulp_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.UUIDField()
key = models.CharField(max_length=200, db_index=True)
key = models.TextField(db_index=True)
value = models.TextField(null=True, db_index=True)

content_object = GenericForeignKey("content_type", "object_id", for_concrete_model=False)
Expand Down
4 changes: 1 addition & 3 deletions pulpcore/app/models/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class FilesystemExporter(Exporter):
TYPE = "filesystem"

path = models.TextField()
method = models.CharField(
choices=FS_EXPORT_CHOICES, default=FS_EXPORT_METHODS.WRITE, max_length=128
)
method = models.TextField(choices=FS_EXPORT_CHOICES, default=FS_EXPORT_METHODS.WRITE)

class Meta:
default_related_name = "%(app_label)s_fs_exporter"
Expand Down
4 changes: 2 additions & 2 deletions pulpcore/app/models/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ProgressReport(BaseModel):
"""

message = models.TextField()
code = models.CharField(max_length=36)
code = models.TextField()
state = models.TextField(choices=TASK_CHOICES, default=TASK_STATES.WAITING)

total = models.IntegerField(null=True)
Expand Down Expand Up @@ -313,7 +313,7 @@ class GroupProgressReport(BaseModel):
"""

message = models.TextField()
code = models.CharField(max_length=36)
code = models.TextField()

total = models.IntegerField(default=0)
done = models.IntegerField(default=0)
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ class RepositoryVersionContentDetails(models.Model):
(REMOVED, "removed"),
)

count_type = models.CharField(max_length=1, choices=COUNT_TYPE_CHOICES)
count_type = models.TextField(choices=COUNT_TYPE_CHOICES)
content_type = models.TextField()
repository_version = models.ForeignKey(
"RepositoryVersion", related_name="counts", on_delete=models.CASCADE
Expand Down
8 changes: 4 additions & 4 deletions pulpcore/app/models/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class Role(BaseModel):
Fields:
name (models.CharField): Unique name of the role.
name (models.TextField): Unique name of the role.
locked (models.BooleanField): Indicator for plugin managed role.
Relations:
permissions (models.ManyToManyField): Permissions to be granted via this role.
"""

name = models.CharField(max_length=128, db_index=True, unique=True)
name = models.TextField(db_index=True, unique=True)
description = models.TextField(null=True)
locked = models.BooleanField(default=False)
permissions = models.ManyToManyField(Permission)
Expand All @@ -43,7 +43,7 @@ class UserRole(BaseModel):
)
role = models.ForeignKey(Role, related_name="object_users", on_delete=models.CASCADE)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True)
object_id = models.CharField(max_length=255, null=True)
object_id = models.TextField(null=True)
content_object = GenericForeignKey("content_type", "object_id", for_concrete_model=False)

class Meta:
Expand All @@ -65,7 +65,7 @@ class GroupRole(BaseModel):
group = models.ForeignKey(Group, related_name="object_roles", on_delete=models.CASCADE)
role = models.ForeignKey(Role, related_name="object_groups", on_delete=models.CASCADE)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True)
object_id = models.CharField(max_length=255, null=True)
object_id = models.TextField(null=True)
content_object = GenericForeignKey("content_type", "object_id", for_concrete_model=False)

class Meta:
Expand Down
10 changes: 5 additions & 5 deletions pulpcore/app/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Task(BaseModel, AutoAddObjPermsMixin):
state (models.TextField): The state of the task
name (models.TextField): The name of the task
logging_cid (models.CharField): The logging CID associated with the task
logging_cid (models.TextField): The logging CID associated with the task
started_at (models.DateTimeField): The time the task started executing
finished_at (models.DateTimeField): The time the task finished executing
error (models.JSONField): Fatal errors generated by the task
Expand All @@ -176,7 +176,7 @@ class Task(BaseModel, AutoAddObjPermsMixin):

state = models.TextField(choices=TASK_CHOICES)
name = models.TextField()
logging_cid = models.CharField(max_length=256, db_index=True, default="")
logging_cid = models.TextField(db_index=True, default="")

started_at = models.DateTimeField(null=True)
finished_at = models.DateTimeField(null=True)
Expand All @@ -194,7 +194,7 @@ class Task(BaseModel, AutoAddObjPermsMixin):
task_group = models.ForeignKey(
"TaskGroup", null=True, related_name="tasks", on_delete=models.SET_NULL
)
reserved_resources_record = ArrayField(models.CharField(max_length=256), null=True)
reserved_resources_record = ArrayField(models.TextField(), null=True)

def __str__(self):
return "Task: {name} [{state}]".format(name=self.name, state=self.state)
Expand Down Expand Up @@ -335,10 +335,10 @@ class CreatedResource(GenericRelationModel):


class TaskSchedule(BaseModel):
name = models.CharField(max_length=256, unique=True, null=False)
name = models.TextField(unique=True, null=False)
next_dispatch = models.DateTimeField(default=timezone.now, null=True)
dispatch_interval = models.DurationField(null=True)
task_name = models.CharField(max_length=256)
task_name = models.TextField()
last_task = models.ForeignKey(Task, null=True, on_delete=models.SET_NULL)

class Meta:
Expand Down

0 comments on commit 18d9f70

Please sign in to comment.