Support file upload for accessibility reports#744
Conversation
…ror in run_migrations
…to work around known issue
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c3c40989e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| (file_type = 'publication' AND publication_id IS NOT NULL AND work_id IS NULL AND additional_resource_id IS NULL AND work_featured_video_id IS NULL) OR | ||
| (file_type = 'additional_resource' AND additional_resource_id IS NOT NULL AND work_id IS NULL AND publication_id IS NULL AND work_featured_video_id IS NULL) OR | ||
| (file_type = 'work_featured_video' AND work_featured_video_id IS NOT NULL AND work_id IS NULL AND publication_id IS NULL AND additional_resource_id IS NULL) OR | ||
| (file_type = 'accessibility_report' AND publication_id IS NOT NULL AND work_id IS NULL AND additional_resource_id IS NULL AND work_featured_video_id IS NULL) |
There was a problem hiding this comment.
Enforce one accessibility report file per publication
This migration adds accessibility_report to the file checks but does not add a matching partial unique index on file(publication_id) for that new file_type. The application path reads by publication with .first() (File::from_publication_id), so concurrent/retried completions can create duplicate accessibility-report rows and then return/update an arbitrary one, leaving stale records and object keys behind. Please add a unique index equivalent to file_publication_unique_idx, filtered to file_type = 'accessibility_report'.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac01c6bf59
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ADD CONSTRAINT file_type_check | ||
| CHECK ( | ||
| (file_type = 'frontcover' AND work_id IS NOT NULL AND publication_id IS NULL AND additional_resource_id IS NULL AND work_featured_video_id IS NULL) OR |
There was a problem hiding this comment.
Purge new file rows before restoring old file_type checks
This rollback can fail in any environment that has already accepted an accessibility_report upload: the down migration re-adds file_type_check/file_upload_type_check without allowing accessibility_report, but it does not delete or migrate existing rows of that type first. In that case, ALTER TABLE ... ADD CONSTRAINT errors and blocks rollback; add a cleanup step for file and file_upload rows with file_type = 'accessibility_report' before recreating the old constraints.
Useful? React with 👍 / 👎.
No description provided.