Menu

State vs steps: Magento 2 declarative schema vs Laravel migrations
📰

State vs steps: Magento 2 declarative schema vs Laravel migrations

DEV Community: laravel·Nikita Sirenko·about 11 hours ago
#ScolPxzn
#devtolaravel#devto#dev#magento#column
Reading 0:00
15s threshold

Magento describes the database you want. Laravel records how you got there. A column rename shows the difference: in Magento it can drop the column with its data, and the dry run that would warn you has a side effect of its own.

Magento: the file is the state

db_schema.xml describes each table as it should be. You change the file, you run bin/magento setup:upgrade , and Magento compares the XML with the live MySQL schema and writes the ALTERs itself. You don't get a history of steps. You get a diff.

One more file takes part. db_schema_whitelist.json lists the columns, indexes and constraints Magento is allowed to drop.

Laravel: the history is the state

Migrations are steps. Each file runs once, and a row in the migrations table remembers it: the file name and the batch number.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.