Skip to content

SQL errors when applying project config after switching git branches #546

@low

Description

@low

Describe the bug

Working on a project with a team, where each member is adding Matrix block types and adding ST fields to them. This results in a mismatch of each developer's list of rows in the matrixblocktypes table, and thus in different stc_ID_HANDLE tables. This can cause issues when trying to sync up the CMS after switching branches, for example:

Applying changes from your project config files ...
- updating superTableBlockTypes.2565261f-97c4-4834-b550-deabb125609b ... 
  - updating matrixBlockTypes ... done
error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbname.stc_64_ctabuttons' doesn't exist
The SQL being executed was: ALTER TABLE `stc_64_ctabuttons` ADD `field_style_abummlrk` varchar(9)

The ID 64 here refers to a different or non-existent Matrix Block Types on my machine, rather than the one the other dev was using.

If instead of the ID, we'd use the first chunk of the UID (which remains unchanged across different envs), the issue would be solved: https://github.com/verbb/super-table/blob/craft-4/src/services/Service.php#L670

This issue looks to be related -- we also use the same ST field setup across different matrix block types.

Steps to reproduce

See above.

Craft CMS version

4.5.11

Plugin version

3.0.12

Multi-site?

Yes

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions