Skip to content

Commit

Permalink
Convert remaining CharField to TextField
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Nov 12, 2019
1 parent 3dfd067 commit 8e8dcb8
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGES/5609.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Database column types using CharField were converted to TextField. This was a restriction leftover from MySQL support which is no longer relevant.
68 changes: 68 additions & 0 deletions pulpcore/app/migrations/0016_charfield_to_textfield.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 2.2.7 on 2019-11-12 20:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0015_auto_20191112_1426'),
]

operations = [
migrations.AlterField(
model_name='basedistribution',
name='base_path',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='basedistribution',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='contentappstatus',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='contentguard',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='filesystemexporter',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='remote',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='repository',
name='name',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='reservedresource',
name='resource',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='reservedresourcerecord',
name='resource',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='task',
name='name',
field=models.TextField(),
),
migrations.AlterField(
model_name='worker',
name='name',
field=models.TextField(db_index=True, unique=True),
),
]
4 changes: 2 additions & 2 deletions pulpcore/app/models/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class FileSystemExporter(MasterModel):
Fields:
name (models.CharField): The exporter unique name.
name (models.TextField): The exporter unique name.
path (models.TextField): a full path where the export will go.
"""

name = models.CharField(db_index=True, unique=True, max_length=255)
name = models.TextField(db_index=True, unique=True)
path = models.TextField()

def _export_to_file_system(self, content_artifacts):
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/app/models/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ProgressReport(Model):
message (models.TextField): short message for the progress update, typically
shown to the user. (required)
code (models.CharField): identifies the type of progress report
code (models.TextField): identifies the type of progress report
state (models.TextField): The state of the progress update. Defaults to `WAITING`. This
field uses a limited set of choices of field states. See `STATES` for possible states.
total: (models.IntegerField) The total count of items to be handled
Expand Down
16 changes: 8 additions & 8 deletions pulpcore/app/models/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class PublishedArtifact(Model):
An artifact that is part of a publication.
Fields:
relative_path (models.CharField): The (relative) path component of the published url.
relative_path (models.TextField): The (relative) path component of the published url.
Relations:
content_artifact (models.ForeignKey): The referenced content artifact.
Expand All @@ -161,7 +161,7 @@ class PublishedMetadata(Content):
Metadata file that is part of a publication.
Fields:
relative_path (models.CharField): The (relative) path component of the published url.
relative_path (models.TextField): The (relative) path component of the published url.
Relations:
publication (models.ForeignKey): The publication in which the artifact is included.
Expand Down Expand Up @@ -230,11 +230,11 @@ class ContentGuard(MasterModel):
We defer to the Django docs on extending this model definition with additional fields.
Fields:
name (models.CharField): Unique guard name.
name (models.TextField): Unique guard name.
description (models.TextField): An optional description.
"""
name = models.CharField(max_length=255, db_index=True, unique=True)
name = models.TextField(db_index=True, unique=True)
description = models.TextField(null=True)

def permit(self, request):
Expand Down Expand Up @@ -264,17 +264,17 @@ class BaseDistribution(MasterModel):
``a/path`` or ``a`` because both are subpaths of ``a/path/foo``.
Fields:
name (models.CharField): The name of the distribution. Examples: "rawhide" and "stable".
base_path (models.CharField): The base (relative) path component of the published url.
name (models.TextField): The name of the distribution. Examples: "rawhide" and "stable".
base_path (models.TextField): The base (relative) path component of the published url.
Relations:
content_guard (models.ForeignKey): An optional content-guard.
remote (models.ForeignKey): A remote that the content app can use to find content not
yet stored in Pulp.
"""

name = models.CharField(max_length=255, db_index=True, unique=True)
base_path = models.CharField(max_length=255, unique=True)
name = models.TextField(db_index=True, unique=True)
base_path = models.TextField(unique=True)

content_guard = models.ForeignKey(ContentGuard, null=True, on_delete=models.SET_NULL)
remote = models.ForeignKey(Remote, null=True, on_delete=models.SET_NULL)
Expand Down
8 changes: 4 additions & 4 deletions pulpcore/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Repository(MasterModel):
Fields:
name (models.CharField): The repository name.
name (models.TextField): The repository name.
description (models.TextField): An optional description.
last_version (models.PositiveIntegerField): A record of the last created version number.
Used when a repository version is deleted so as not to create a new vesrion with the
Expand All @@ -42,7 +42,7 @@ class Repository(MasterModel):
"""
TYPE = 'repository'

name = models.CharField(db_index=True, unique=True, max_length=255)
name = models.TextField(db_index=True, unique=True)
description = models.TextField(null=True)
last_version = models.PositiveIntegerField(default=0)
content = models.ManyToManyField('Content', through='RepositoryContent',
Expand Down Expand Up @@ -127,7 +127,7 @@ class Remote(MasterModel):
Fields:
name (models.CharField): The remote name.
name (models.TextField): The remote name.
url (models.TextField): The URL of an external content source.
ca_cert (models.FileField): A PEM encoded CA certificate used to validate the
server certificate presented by the external source.
Expand Down Expand Up @@ -164,7 +164,7 @@ class Remote(MasterModel):
'future requests for that same content to have to be downloaded again.')
)

name = models.CharField(db_index=True, unique=True, max_length=255)
name = models.TextField(db_index=True, unique=True)

url = models.TextField()

Expand Down
4 changes: 2 additions & 2 deletions pulpcore/app/models/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class ContentAppStatus(Model):
Fields:
name (models.CharField): The name of the content app
name (models.TextField): The name of the content app
last_heartbeat (models.DateTimeField): A timestamp of this worker's last heartbeat
"""
objects = ContentAppStatusManager()

name = models.CharField(db_index=True, unique=True, max_length=255)
name = models.TextField(db_index=True, unique=True)
last_heartbeat = models.DateTimeField(auto_now=True)

@property
Expand Down
12 changes: 6 additions & 6 deletions pulpcore/app/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ReservedResource(Model):
task (models.ForeignKey): The task associated with this reservation
worker (models.ForeignKey): The worker associated with this reservation
"""
resource = models.CharField(max_length=255, unique=True)
resource = models.TextField(unique=True)

tasks = models.ManyToManyField("Task", related_name="reserved_resources",
through='TaskReservedResource')
Expand Down Expand Up @@ -75,7 +75,7 @@ class ReservedResourceRecord(Model):
task (models.ForeignKey): The task associated with this reservation
"""

resource = models.CharField(max_length=255, unique=True)
resource = models.TextField(unique=True)
tasks = models.ManyToManyField("Task", related_name="reserved_resources_record",
through='TaskReservedResourceRecord')

Expand Down Expand Up @@ -222,15 +222,15 @@ class Worker(Model):
Fields:
name (models.CharField): The name of the worker, in the format "worker_type@hostname"
name (models.TextField): The name of the worker, in the format "worker_type@hostname"
last_heartbeat (models.DateTimeField): A timestamp of this worker's last heartbeat
gracefully_stopped (models.BooleanField): True if the worker has gracefully stopped. Default
is False.
cleaned_up (models.BooleanField): True if the worker has been cleaned up. Default is False.
"""
objects = WorkerManager()

name = models.CharField(db_index=True, unique=True, max_length=255)
name = models.TextField(db_index=True, unique=True)
last_heartbeat = models.DateTimeField(auto_now=True)
gracefully_stopped = models.BooleanField(default=False)
cleaned_up = models.BooleanField(default=False)
Expand Down Expand Up @@ -312,7 +312,7 @@ class Task(Model):
Fields:
state (models.TextField): The state of the task
name (models.CharField): The name of the task
name (models.TextField): The name of the task
started_at (models.DateTimeField): The time the task started executing
finished_at (models.DateTimeField): The time the task finished executing
error (pulpcore.app.fields.JSONField): Fatal errors generated by the task
Expand All @@ -323,7 +323,7 @@ class Task(Model):
worker (models.ForeignKey): The worker that this task is in
"""
state = models.TextField(choices=TASK_CHOICES)
name = models.CharField(max_length=255)
name = models.TextField()

started_at = models.DateTimeField(null=True)
finished_at = models.DateTimeField(null=True)
Expand Down
8 changes: 1 addition & 7 deletions pulpcore/app/serializers/exporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from gettext import gettext as _

from django.core import validators
from rest_framework import serializers
from rest_framework.validators import UniqueValidator

Expand All @@ -19,12 +18,7 @@ class FileSystemExporterSerializer(ModelSerializer):
pulp_href = DetailIdentityField()
name = serializers.CharField(
help_text=_("Unique name of the file system exporter."),
validators=[validators.MaxLengthValidator(
models.FileSystemExporter._meta.get_field('name').max_length,
message=_('`name` length must be less than {} characters').format(
models.FileSystemExporter._meta.get_field('name').max_length
)),
UniqueValidator(queryset=models.BaseDistribution.objects.all())]
validators=[UniqueValidator(queryset=models.BaseDistribution.objects.all())]
)
path = serializers.CharField(
help_text=_("File system location to export to.")
Expand Down
16 changes: 2 additions & 14 deletions pulpcore/app/serializers/publication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from gettext import gettext as _

from django.core import validators
from django.db.models import Q
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
Expand Down Expand Up @@ -104,13 +103,7 @@ class BaseDistributionSerializer(ModelSerializer):
base_path = serializers.CharField(
help_text=_('The base (relative) path component of the published url. Avoid paths that \
overlap with other distribution base paths (e.g. "foo" and "foo/bar")'),
validators=[validators.MaxLengthValidator(
models.BaseDistribution._meta.get_field('base_path').max_length,
message=_('`base_path` length must be less than {} characters').format(
models.BaseDistribution._meta.get_field('base_path').max_length
)),
UniqueValidator(queryset=models.BaseDistribution.objects.all()),
]
validators=[UniqueValidator(queryset=models.BaseDistribution.objects.all())]
)
base_url = BaseURLField(
source='base_path', read_only=True,
Expand All @@ -124,12 +117,7 @@ class BaseDistributionSerializer(ModelSerializer):
)
name = serializers.CharField(
help_text=_('A unique name. Ex, `rawhide` and `stable`.'),
validators=[validators.MaxLengthValidator(
models.BaseDistribution._meta.get_field('name').max_length,
message=_('`name` length must be less than {} characters').format(
models.BaseDistribution._meta.get_field('name').max_length
)),
UniqueValidator(queryset=models.BaseDistribution.objects.all())]
validators=[UniqueValidator(queryset=models.BaseDistribution.objects.all())]
)

class Meta:
Expand Down

0 comments on commit 8e8dcb8

Please sign in to comment.