Video Lesson: Create a new database table in Magento

Create a new database table in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

Create a new database table in Magento

Learn how to create a new Magento 2 database table with db_schema.xml for a custom blog post entity.

Lesson Content

Just like this vendor/magento/module-catalog/etc/db_schema.xml file in the Magento Catalog module, we will create our own using this schema node as the base. Let’s copy the prolog and this node, and paste it into our own db_schema.xml file.

Our db file will go in our etc folder, and be named db_schema.xml. Let’s paste in the contents, removing the Magento comments since this will be our module. Then we can close up this schema node.

<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        x...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.