mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 10:51:08 -05:00
feat: Refactor rides app with unique constraints, mixins, and enhanced documentation
- Added migration to convert unique_together constraints to UniqueConstraint for RideModel. - Introduced RideFormMixin for handling entity suggestions in ride forms. - Created comprehensive code standards documentation outlining formatting, docstring requirements, complexity guidelines, and testing requirements. - Established error handling guidelines with a structured exception hierarchy and best practices for API and view error handling. - Documented view pattern guidelines, emphasizing the use of CBVs, FBVs, and ViewSets with examples. - Implemented a benchmarking script for query performance analysis and optimization. - Developed security documentation detailing measures, configurations, and a security checklist. - Compiled a database optimization guide covering indexing strategies, query optimization patterns, and computed fields.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Convert RideModel unique_together to UniqueConstraint.
|
||||
|
||||
This migration converts the legacy unique_together constraints to the modern
|
||||
UniqueConstraint syntax which provides better error messages and more flexibility.
|
||||
"""
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rides', '0025_convert_ride_status_to_fsm'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Remove the old unique_together constraint
|
||||
migrations.AlterUniqueTogether(
|
||||
name='ridemodel',
|
||||
unique_together=set(),
|
||||
),
|
||||
# Add new UniqueConstraints with better error messages
|
||||
migrations.AddConstraint(
|
||||
model_name='ridemodel',
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=['manufacturer', 'name'],
|
||||
name='ridemodel_manufacturer_name_unique',
|
||||
violation_error_message='A ride model with this name already exists for this manufacturer'
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='ridemodel',
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=['manufacturer', 'slug'],
|
||||
name='ridemodel_manufacturer_slug_unique',
|
||||
violation_error_message='A ride model with this slug already exists for this manufacturer'
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user