-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blobs: prevent NULL contentType in db #1355
base: master
Are you sure you want to change the base?
blobs: prevent NULL contentType in db #1355
Conversation
Set blob."contentType" values to application/octet-stream if no mime type is supplied on upload. Related: getodk#1351
lib/model/migrations/20250113-01-disable-nullable-blob-content-types.js
Outdated
Show resolved
Hide resolved
The outcome here looks as I would expect it. Would the migration possibly be time-consuming if an install has a lot of blobs? Or would it only be the case if there are lots of blobs with |
What would be realistic numbers? I've run on a fresh db, and got the following numbers:
|
lib/model/migrations/20250113-01-disable-nullable-blob-content-types.js
Outdated
Show resolved
Hide resolved
There's a very big range, including up to the several millions so we would want to document this as possibly time-consuming in the release notes. It feels to me like the way to set the default values is really inefficient but I'm not sure whether there's an alternative - https://github.com/getodk/central-backend/pull/1355/files#r1925735636 |
How about this? UPDATE blobs SET "contentType"='application/octet-stream' WHERE "contentType" IS NULL;
ALTER TABLE blobs
ALTER COLUMN "contentType" SET DEFAULT 'application/octet-stream',
ALTER COLUMN "contentType" SET NOT NULL New results:
|
@lognaturel if it's helpful, we could include an additional test for the speed of the migration, e.g. this checks that 1,000,000 can be migrated in less than 5s: |
Sweet, thanks! I don't feel like we need to have a test since we don't change migrations and I can't imagine we'll layer more onto this one. With these new timings I don't think we need to document anything about the migration. |
Set
blob."contentType"
values to application/octet-stream if no mime type is supplied on upload.Related: #1351
What has been done to verify that this works as intended?
CI.
Why is this the best possible solution? Were any other approaches considered?
Discussion on #1351.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This will change
Content-Type
headers for files uploaded without one from the stringnull
to the stringapplication/octet-stream
.Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
Yes.
Before submitting this PR, please make sure you have:
make test
and confirmed all checks still pass OR confirm CircleCI build passes