0

I am creating a custom Module, in that I created a custom table and patch data. The patch data for inserting data into that table. Now the issue is, the custom table was created through declarative schema, when I am installing a module, the patch data get executed before table creation, so it is throwing errors. I would like to add table schema as a dependency in setup patch data using public static function getDependencies() function.

Is this possible to add table schema as a dependency in setup patch data? If not please suggest me a better solution to fix this.

Note: I don't want to use setup scripts (Install/Upgrade scripts) to create tables. I just want to achieve this with declarative schema.

Thanks in advance!

1 Answer 1

1

Would suggest checking at first whether a table exists in your patch (i.e $setup->getConnection()->isTableExists()) or not.

If it doesn't exist first create the table then you may insert your data, you can take reference of the below file path if that helps:

vendor/magento/module-catalog/Setup/Patch/Schema/EnableSegmentation.php 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.