mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 08:31:07 -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,25 @@
|
||||
"""
|
||||
Add GIN index for Company.roles ArrayField.
|
||||
|
||||
This improves query performance for queries like:
|
||||
Company.objects.filter(roles__contains=["MANUFACTURER"])
|
||||
Company.objects.filter(roles__contains=["OPERATOR"])
|
||||
|
||||
GIN indexes are specifically designed for array containment queries in PostgreSQL.
|
||||
"""
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0022_alter_company_roles_alter_companyevent_roles'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
sql="CREATE INDEX IF NOT EXISTS parks_company_roles_gin_idx ON parks_company USING gin(roles);",
|
||||
reverse_sql="DROP INDEX IF EXISTS parks_company_roles_gin_idx;",
|
||||
),
|
||||
]
|
||||
28
backend/apps/parks/migrations/0024_add_timezone_default.py
Normal file
28
backend/apps/parks/migrations/0024_add_timezone_default.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
Add default value 'UTC' to Park.timezone field.
|
||||
|
||||
This ensures all new parks have a valid timezone and existing parks
|
||||
without a timezone get a sensible default.
|
||||
"""
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0023_add_company_roles_gin_index'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='timezone',
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default='UTC',
|
||||
help_text="Timezone identifier for park operations (e.g., 'America/New_York')",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user