Skip to content
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

bin/magento setup:db:status does not recognize JSON type #38278

Open
1 of 5 tasks
MTheProgrammer opened this issue Dec 13, 2023 · 7 comments
Open
1 of 5 tasks

bin/magento setup:db:status does not recognize JSON type #38278

MTheProgrammer opened this issue Dec 13, 2023 · 7 comments
Labels
Area: Framework Component: Setup Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@MTheProgrammer
Copy link

MTheProgrammer commented Dec 13, 2023

Preconditions and environment

  • Magento 2.4.6-p3
  • MariaDB:10.6

Command setup:db:status is useful for deployment tools to determine whether setup:upgrade should be run.

Steps to reproduce

Create a module with a new table with JSON column:

db_schema.xml:

    <table name="example_table" engine="innodb" resource="default">
        <column xsi:type="int" name="entity_id" identity="true" nullable="false" unsigned="true"/>
        <column xsi:type="json" name="content" nullable="false"/>
        <constraint referenceId="PRIMARY" xsi:type="primary">
            <column name="feed_missing_id"/>
        </constraint>
    </table>

Run

bin/magento setup:db-declaration:generate-whitelist --module-name Sample_Module
bin/magento setup:upgrade
bin/magento setup:db:status

Expected result

Reported schema is up to date

Actual result

Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

Additional information

You can debug results with breakpoint or var_dump in
\Magento\Framework\Setup\Declaration\Schema\UpToDateDeclarativeSchema::isUpToDate

Search for old and new phrases, e.g. bin/magento setup:db:status | grep old -n10. Following results indicate that the column type is resolved from the database as longtext but the new value is json. JSON is stored as longtext and the diff will always report that columns differ.

Perhaps this is only an issue in MariaDB because JSON is an alias for LONGTEXT and should work fine on MySQL.

Sample output:

bin/magento setup:db:status | grep old -n10
12467:    ["old":"Magento\Framework\Setup\Declaration\Schema\ElementHistory":private]=>
12468-    object(Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Text)#14665 (6) {
12469-      ["type":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
12470-      string(8) "longtext"
12471-      ["name":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
12472-      string(7) "content"
12473-      ["table":"Magento\Framework\Setup\Declaration\Schema\Dto\Column":private]=>
12474-      object(Magento\Framework\Setup\Declaration\Schema\Dto\Table)#14661 (13) {
12475-        ["type":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
12476-        string(5) "table"
12477-        ["name":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
bin/magento setup:db:status | grep new -n10
1-array(1) {
2-  [0]=>
3-  object(Magento\Framework\Setup\Declaration\Schema\ElementHistory)#15359 (2) {
4:    ["new":"Magento\Framework\Setup\Declaration\Schema\ElementHistory":private]=>
5-    object(Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Blob)#8029 (6) {
6-      ["type":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
7-      string(4) "json"
8-      ["name":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
9-      string(7) "content"
10-      ["table":"Magento\Framework\Setup\Declaration\Schema\Dto\Column":private]=>
11-      object(Magento\Framework\Setup\Declaration\Schema\Dto\Table)#8025 (13) {
12-        ["type":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>
13-        string(5) "table"
14-        ["name":"Magento\Framework\Setup\Declaration\Schema\Dto\GenericElement":private]=>

Workaround: use longtext instead of json.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Dec 13, 2023

Hi @MTheProgrammer. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board Dec 13, 2023
@engcom-Bravo engcom-Bravo added Reported on 2.4.6-p3 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it labels Dec 13, 2023
@engcom-November engcom-November self-assigned this Dec 13, 2023
Copy link

m2-assistant bot commented Dec 13, 2023

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link

Hello @MTheProgrammer,

Thank you for the report and collaboration!

We tried to reproduce this issue on 2.4-develop, but in our case it is not reproducible.
Created a db_schema.xml with JSON column in a custom module, generated db_schema_whitelist and ran setup:upgrade and setup:db:status, and got the expected result.
Please take a look at the screenshot:
image

Please find the custom module used here, and let us know if we are missing anything.
DbVendor.zip

Thank you.

@engcom-November engcom-November added the Issue: needs update Additional information is require, waiting for response label Dec 13, 2023
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Dec 13, 2023
@MTheProgrammer
Copy link
Author

MTheProgrammer commented Dec 13, 2023

Hello, thank you for the quick response. Have you tested with MySQL or MariaDB? The problem only affects MariaDB.

You can use Mark Shust's docker for Magento to quickly setup the infrastructure.

I was able to reproduce the issue with your custom module.

@engcom-November
Copy link

engcom-November commented Dec 21, 2023

Hello @MTheProgrammer,

Thank you for the quick response!

We were able to verify this issue on 2.4-develop with MariaDB as database.
After setup:upgrade when running setup:db:status we got the result as Declarative Schema is not up to date.
Please take a look at the screenshot below:
image

Hence confirming the issue.

Thank you.

@engcom-November engcom-November added Component: Setup Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Dec 21, 2023
@m2-community-project m2-community-project bot moved this from Needs Update to Confirmed in Issue Confirmation and Triage Board Dec 21, 2023
@m2-community-project m2-community-project bot removed the Issue: needs update Additional information is require, waiting for response label Dec 21, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-10737 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Dec 21, 2023

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Dec 21, 2023
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Setup Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
High Priority Backlog
  
Ready for Development
Development

No branches or pull requests

5 participants