diff --git a/newdle/migrations/alembic.ini b/newdle/migrations/alembic.ini index e0be0386..32eab5af 100644 --- a/newdle/migrations/alembic.ini +++ b/newdle/migrations/alembic.ini @@ -1,5 +1,6 @@ [alembic] file_template = %%(year)d%%(month).2d%%(day).2d_%%(hour).2d%%(minute).2d_%%(rev)s_%%(slug)s +script_location = newdle/migrations # Logging configuration [loggers] diff --git a/newdle/migrations/versions/20250704_1127_cab5d47c1152_ensure_participant_names.py b/newdle/migrations/versions/20250704_1127_cab5d47c1152_ensure_participant_names.py new file mode 100644 index 00000000..2a4eb7f1 --- /dev/null +++ b/newdle/migrations/versions/20250704_1127_cab5d47c1152_ensure_participant_names.py @@ -0,0 +1,28 @@ +"""Ensure participant names + +Revision ID: cab5d47c1152 +Revises: 30b5fe7b5949 +Create Date: 2025-07-04 11:27:08.792500 +""" + +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'cab5d47c1152' +down_revision = '30b5fe7b5949' +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute( + """ + UPDATE participants + SET name = '?' + WHERE name= ''; + """ + ) + + +def downgrade(): + pass diff --git a/newdle/schemas.py b/newdle/schemas.py index 6b9f4a0e..917ae75b 100644 --- a/newdle/schemas.py +++ b/newdle/schemas.py @@ -131,6 +131,11 @@ class ParticipantSchema(mm.Schema): ) ) + @validates('name') + def name_not_empty(self, value): + if not value: + raise ValidationError('This field cannot be empty.') + class RestrictedParticipantSchema(ParticipantSchema): class Meta: