[Bug]: PostgreSQL duplicate key value violates unique constraint "mimetype_id_index"
Open
Nobody has claimed this yet.
0. Needs triage
31-feedback
bug
feature: database
feature: files
feature: install and update
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Hello,
on a fresh installation on Debian 12 with PostgreSQL I got: the following error in the postgresql.log:
025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud ERROR: duplicate key value violates unique constraint "mimetype_id_index"
2025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud DETAIL: Key (mimetype)=(image/svg+xml) already exists.
2025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud STATEMENT: INSERT INTO "oc_mimetypes" ("mimetype") VALUES($1)
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud ERROR: duplicate key value violates unique constraint "mimetype_id_index"
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud DETAIL: Key (mimetype)=(image/svg+xml) already exists.
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud STATEMENT: INSERT INTO "oc_mimetypes" ("mimetype") VALUES($1)
Steps to reproduce
- Install Debian 12 in a LXC container
- install all dependencies and nextcloud
- configure postgresql
- install + configure nextcloud
Expected behavior
No error messages in a fresh installation
Nextcloud Server version
31
Operating system
Debian 12
PHP engine version
8.2
Web server
Apache 2.4.62
Database engine version
PostgreSQL 15.13
Is this bug present after an update or on a fresh install?
yes
Are you using the Nextcloud Server Encryption module?
no
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file, test, or entry point is named. Reproduce the fresh Debian 12 installation with PostgreSQL 15.13, then trace the oc_mimetypes insertion that produces the duplicate image/svg+xml error. Done means a fresh Nextcloud 31 installation completes without duplicate-key errors and the relevant regression coverage passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- apache, debian, php, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100