module-setup

Create Magento 2 database setup instructions for declarative schema and data migrations.

2|3|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/caravanglory/magehub --skill module-setup
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: module-setup
Source: https://github.com/caravanglory/magehub/tree/main/skills/module/module-setup
Command: npx skills add https://github.com/caravanglory/magehub --skill module-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Magento 2 developers define and migrate database structure and setup-time data changes safely, without relying on legacy setup scripts.

Core Features & Use Cases

  • Declarative schema for tables, columns, indexes, and foreign keys in db_schema.xml.
  • Idempotent data patches for attributes, seed data, and migrations.
  • Schema patches for rare DDL tasks that declarative schema cannot express.
  • Use it when adding a custom entity table, updating product attributes, or regenerating the schema whitelist for a module.

Quick Start

Ask the Skill to create or update the Magento module's db_schema.xml, data patches, and whitelist for your target tables and data migrations.

Frequently Asked Questions about module-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a declarative db_schema.xml for a custom Magento 2 module table?▼

Declarative db_schema.xml for Magento 2 defines tables, columns, indexes, and foreign keys safely. You specify the target database structure in the XML file, and the system generates the setup:upgrade instructions to apply it.

What is the best way to add product attributes and seed data in Magento 2 without legacy setup scripts?▼

Idempotent data patches are the best way to add product attributes and seed data without legacy scripts. They replace upgrade scripts by applying setup-time data migrations safely and only once during setup:upgrade.

When do I need a schema patch instead of declarative schema in Magento 2?▼

Schema patches are needed for rare DDL tasks that declarative schema cannot express in Magento 2. Use them only for complex database structure changes that db_schema.xml does not support, ensuring safe setup:upgrade execution.

How do I regenerate the schema whitelist for a Magento 2 module?▼

To regenerate the schema whitelist for a Magento 2 module, you run the whitelist regeneration process after updating db_schema.xml. This ensures declarative schema validation passes and tracks allowed database structure changes.

Why do my Magento 2 data patches fail during setup:upgrade?▼

Magento 2 data patches fail during setup:upgrade if they lack idempotent logic, proper dependency ordering, or schema validation. Ensure patch logic is idempotent and dependencies are explicitly ordered to prevent setup:upgrade failures.

Does Magento 2 declarative schema support complex database migrations and foreign keys?▼

Magento 2 declarative schema supports foreign keys, indexes, columns, and tables in db_schema.xml. For complex database migrations involving rare DDL tasks, use schema patches alongside declarative schema for safe setup execution.