# Implementation Plan

- [x] 1. Create database migration script





  - Create migration script to add project_id column to shots table
  - Add foreign key constraint to projects table
  - Create indexes for performance optimization
  - Populate project_id for existing shots based on episode relationships
  - Add unique constraint for project-scoped shot names
  - _Requirements: 2.1, 2.2, 2.3, 2.4, 2.5_

- [ ]* 1.1 Write property test for migration data preservation
  - **Property 4: Migration Data Preservation**
  - **Validates: Requirements 2.4, 2.5**

- [x] 2. Update Shot model and relationships





  - Add project_id column to Shot SQLAlchemy model
  - Add project relationship to Shot model
  - Update Project model to include shots back-reference
  - Add project-scoped uniqueness constraint
  - _Requirements: 1.1, 1.2, 2.1, 2.2_

- [ ]* 2.1 Write property test for project-episode consistency
  - **Property 1: Project-Episode Consistency**
  - **Validates: Requirements 1.2, 3.3, 4.2**

- [ ]* 2.2 Write property test for project-scoped name uniqueness
  - **Property 2: Project-Scoped Name Uniqueness**
  - **Validates: Requirements 1.1, 1.4**

- [x] 3. Update Pydantic schemas





  - Add project_id field to ShotBase schema
  - Update ShotResponse to include project_id
  - Add optional project_name computed field
  - Maintain backward compatibility for existing schemas
  - _Requirements: 1.3, 3.1, 4.1_

- [ ]* 3.1 Write property test for API response completeness
  - **Property 3: API Response Completeness**
  - **Validates: Requirements 1.3, 3.1, 4.1**

- [x] 4. Update shot router endpoints





  - Modify shot creation to auto-populate project_id from episode
  - Add project_id validation in shot creation and updates
  - Update shot querying to include project_id filtering
  - Ensure project-scoped name uniqueness validation
  - _Requirements: 1.1, 1.2, 1.4, 3.2, 3.4_

- [ ]* 4.1 Write property test for project filtering accuracy
  - **Property 5: Project Filtering Accuracy**
  - **Validates: Requirements 3.4**

- [x] 5. Update bulk shot creation





  - Modify bulk shot creation to validate project consistency
  - Ensure all shots in bulk operation belong to same project as episode
  - Update bulk validation logic for project-scoped uniqueness
  - _Requirements: 3.5_

- [ ]* 5.1 Write property test for bulk operation consistency
  - **Property 6: Bulk Operation Consistency**
  - **Validates: Requirements 3.5**

- [x] 6. Update soft deletion service





  - Ensure project_id is preserved during soft deletion
  - Update recovery operations to maintain project relationships
  - Verify project_id consistency in deletion info endpoints
  - _Requirements: 4.5_

- [ ]* 6.1 Write property test for soft deletion project preservation
  - **Property 7: Soft Deletion Project Preservation**
  - **Validates: Requirements 4.5**

- [x] 7. Update frontend TypeScript interfaces





  - Add project_id to Shot interface
  - Update ShotCreate and ShotUpdate interfaces
  - Add optional project_name field for display
  - Maintain backward compatibility
  - _Requirements: 3.1, 4.1_

- [x] 8. Update frontend shot service




  - Modify shot service to handle project_id in responses
  - Add project filtering support to shot queries
  - Update error handling for project-related validation errors
  - _Requirements: 3.1, 3.4, 4.1_

- [x] 9. Update shot form components





  - Display project context in shot forms where appropriate
  - Handle project-scoped validation errors
  - Maintain existing form functionality
  - _Requirements: 4.1, 4.3_

- [x] 10. Checkpoint - Ensure all tests pass





  - Ensure all tests pass, ask the user if questions arise.

- [ ]* 10.1 Write property test for permission system continuity
  - **Property 8: Permission System Continuity**
  - **Validates: Requirements 4.4**

- [-] 11. Run database migration



  - Execute migration script on development database
  - Verify data integrity after migration
  - Test all shot operations with new schema
  - _Requirements: 2.1, 2.2, 2.3, 2.4, 2.5_

- [ ]* 11.1 Write unit tests for migration script
  - Test migration with various data scenarios
  - Test constraint creation and validation
  - Test rollback procedures

- [ ] 12. Integration testing
  - Test complete shot workflows with project_id
  - Verify API backward compatibility
  - Test frontend integration with new schema
  - Test performance with project-scoped queries
  - _Requirements: 4.1, 4.2, 4.4_

- [ ]* 12.1 Write integration tests for shot workflows
  - Test shot creation, update, and deletion workflows
  - Test bulk operations with project validation
  - Test API filtering and querying

- [ ] 13. Final checkpoint - Ensure all tests pass
  - Ensure all tests pass, ask the user if questions arise.