Skip to content

Conversation

@AlbertoCalvoRubio
Copy link

@AlbertoCalvoRubio AlbertoCalvoRubio commented Sep 19, 2025

What does it do?

Fix #24421

Why is it needed?

Describe the issue you are solving.

  • It uses the previous schema stored in the strapi_database_schema table to compare changes to not recreate indexes as the order of the columns array is the same. It also avoids doing a lot of queries to the database to know the current schema if it was already stored in the strapi_database_schema table.

How to test it?

Provide information about the environment and the path to verify the behaviour.

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request

@strapi-cla
Copy link

strapi-cla commented Sep 19, 2025

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Sep 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
contributor-docs Ready Ready Preview Comment Sep 23, 2025 6:56am

Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR.

Unfortunately we can't go with this approach quiet yet, we intentionnaly re-inspect the schema to manage cases where users manually add things in there DB or run operations outside Strapi.

If you added an option to switch this behavior on/off that would allows us to move forward with this :)

@AlbertoCalvoRubio
Copy link
Author

Hi, thanks for the PR.

Unfortunately we can't go with this approach quiet yet, we intentionnaly re-inspect the schema to manage cases where users manually add things in there DB or run operations outside Strapi.

If you added an option to switch this behavior on/off that would allows us to move forward with this :)

I've added a strictSynchSchema database setting, similar to forceMigration or runMigration. It is enabled by default (current behaviour), and it can be disabled.
Also, I noticed that comparing the schemas, being both created from the Strapi metadata, needed a fix when comparing column types.
Let me know what you think of this approach, and then I will document this new option in the @strapi/documentation repository.

@alexandrebodin
Copy link
Member

@AlbertoCalvoRubio Thanks that looks pretty good to me, nice catch on the bug.

@derrickmehaffy could you give this a try when you can ? I think this is a nice addition that we could make the default in the next major to reduce bootstrap time :)

@derrickmehaffy
Copy link
Member

@AlbertoCalvoRubio Thanks that looks pretty good to me, nice catch on the bug.

@derrickmehaffy could you give this a try when you can ? I think this is a nice addition that we could make the default in the next major to reduce bootstrap time :)

Should we also port this to v5? Atm it targets v4

@derrickmehaffy derrickmehaffy added source: core:database Source is core/database package pr: enhancement This PR adds or updates some part of the codebase or features labels Sep 22, 2025
@derrickmehaffy derrickmehaffy added this to the 4.25.24 milestone Sep 22, 2025
@derrickmehaffy derrickmehaffy added the flag: documentation This PR requires a documentation update label Sep 22, 2025
@derrickmehaffy
Copy link
Member

Hey Alberto,

Can you quickly run prettier against this so that test can pass? Likewise would you be willing to open a PR for the documentation to add the option?

Specifically for the docs, the repo/branch for v4 is here: https://github.com/strapi/documentation/tree/v4

Copy link
Member

@derrickmehaffy derrickmehaffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minus the doc requirement and the failing prettier test. Makes sense to me.

@alexandrebodin
Copy link
Member

Member

We pbl have the same thing in v5 I don't recall us changing it so if you can make a PR against develop after that one get's merged that would be 💯

@AlbertoCalvoRubio
Copy link
Author

Hey Alberto,

Can you quickly run prettier against this so that test can pass? Likewise would you be willing to open a PR for the documentation to add the option?

Specifically for the docs, the repo/branch for v4 is here: https://github.com/strapi/documentation/tree/v4

I've fixed the formatting issue and created a PR to the documentation repository strapi/documentation#2724.

@AlbertoCalvoRubio
Copy link
Author

Member

We pbl have the same thing in v5 I don't recall us changing it so if you can make a PR against develop after that one get's merged that would be 💯

Sure, I will do the same for v5 once this gets merged. Thanks for the quick feedback!

@derrickmehaffy derrickmehaffy removed the flag: documentation This PR requires a documentation update label Sep 23, 2025
@derrickmehaffy derrickmehaffy merged commit 94fa63a into strapi:v4 Sep 23, 2025
102 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: enhancement This PR adds or updates some part of the codebase or features source: core:database Source is core/database package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants