Any modification on database schema results in application crash

System Information
  • Strapi Version: 4.24.2
  • Operating System: Heroku-22
  • Database: Postgres
  • Node Version: 22.2.0

Hey everyone,
I migrated Strapi from v3 to v4 using migration-scripts/v3-sql-v4-sql at main · strapi/migration-scripts · GitHub
Things are running fine locally and on Heroku. I can apply changes to the database schema locally without any problems. But when I push to Heroku the application cannot be build and fails with the following:

app[web.1]: [2024-05-19 23:43:20.603] debug: ⛔️ Server wasn't able to start properly.
app[web.1]: [2024-05-19 23:43:20.604] error: alter table "public"."files" add constraint "files_created_by_id_fk" foreign key ("created_by_id") references "public"."admin_users" ("id") on delete SET NULL - insert or update on table "files" violates foreign key constraint "files_created_by_id_fk"
app[web.1]: error: alter table "public"."files" add constraint "files_created_by_id_fk" foreign key ("created_by_id") references "public"."admin_users" ("id") on delete SET NULL - insert or update on table "files" violates foreign key constraint "files_created_by_id_fk"
app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:283:98)
app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:122:29)
app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:35:38)
app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
app[web.1]: at TLSSocket.emit (node:events:520:28)
app[web.1]: at TLSSocket.emit (node:domain:488:12)
app[web.1]: at addChunk (node:internal/streams/readable:559:12)
app[web.1]: at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
app[web.1]: at Readable.push (node:internal/streams/readable:390:5)
app[web.1]: at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)

When I undo my changes and push again to Heroku, the application starts again.
I’m quite at a loss as to what to do.