{"id":151,"date":"2021-06-05T11:10:51","date_gmt":"2021-06-05T11:10:51","guid":{"rendered":"http:\/\/thekraftors.com\/blog\/?p=151"},"modified":"2021-06-05T19:22:03","modified_gmt":"2021-06-05T19:22:03","slug":"magento2-data-schema-patch","status":"publish","type":"post","link":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/","title":{"rendered":"Create Data and Schema Patches in Magento 2"},"content":{"rendered":"\n<p>A data patch is a class that contains data modification instructions like update, Insert, delete. <br>A schema patch is a class that contains schema modification instructions like create, drop, alter.<br><br>1. It is defined in a\u00a0<code><strong>&lt;Vendor>\/&lt;Module_Name>\/Setup\/Patch\/Data\/&lt;Patch_Name>.php<\/strong><\/code>\u00a0file and implements\u00a0<strong><code>\\Magento\\Framework\\Setup\\Patch\\DataPatchInterface<\/code> <\/strong><br><br>2. Patches will only be applied <strong>Once<\/strong>. <br><br>3. A list of applied patches is stored in the\u00a0<code><strong>patch_list<\/strong><\/code>\u00a0database table. <br><br>4. A patch will be applied when running the\u00a0<code><strong>setup:upgrade<\/strong><\/code>\u00a0from the Magento CLI.<br><br>To access the example on github <a href=\"https:\/\/github.com\/thekraftors\/Magento2-schema-patch\" target=\"_blank\" rel=\"noreferrer noopener\">Click here<\/a>. Or click on this link <br><a href=\"https:\/\/github.com\/thekraftors\/Magento2-schema-patch\">https:\/\/github.com\/thekraftors\/Magento2-schema-patch<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create Data and Schema Patches in Magento 2 - The Kraftors<\/title>\n<meta name=\"description\" content=\"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Data and Schema Patches in Magento 2 - The Kraftors\" \/>\n<meta property=\"og:description\" content=\"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/\" \/>\n<meta property=\"og:site_name\" content=\"The Kraftors\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/thekraftors\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thekraftors\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-05T11:10:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-05T19:22:03+00:00\" \/>\n<meta name=\"author\" content=\"Kraftors Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@the_kraftors\" \/>\n<meta name=\"twitter:site\" content=\"@the_kraftors\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kraftors Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/\",\"url\":\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/\",\"name\":\"Create Data and Schema Patches in Magento 2 - The Kraftors\",\"isPartOf\":{\"@id\":\"https:\/\/thekraftors.com\/blog\/#website\"},\"datePublished\":\"2021-06-05T11:10:51+00:00\",\"dateModified\":\"2021-06-05T19:22:03+00:00\",\"author\":{\"@id\":\"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/df365c3dc0480599d26a96c6969916d0\"},\"description\":\"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.\",\"breadcrumb\":{\"@id\":\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/thekraftors.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create Data and Schema Patches in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/thekraftors.com\/blog\/#website\",\"url\":\"https:\/\/thekraftors.com\/blog\/\",\"name\":\"The Kraftors\",\"description\":\"AI | AR | eCommerce | Devops | Magento | Flutter\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/thekraftors.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/df365c3dc0480599d26a96c6969916d0\",\"name\":\"Kraftors Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4f2f688e3509fd8078a6d7d68b748268f9e105fb8b8265685b14254ca45f2448?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4f2f688e3509fd8078a6d7d68b748268f9e105fb8b8265685b14254ca45f2448?s=96&d=mm&r=g\",\"caption\":\"Kraftors Team\"},\"description\":\"At Kraftors, we offer IT Services related to development in E-Commerce Development , AI \/ ML Development, AR\/VR Development, Mobile Application Development, DevOps \/ MLOps, and Custom Development\",\"sameAs\":[\"http:\/\/thekraftors.com\/blog\",\"https:\/\/www.facebook.com\/thekraftors\/\",\"https:\/\/www.instagram.com\/the_kraftors\/\",\"https:\/\/www.linkedin.com\/company\/kraftors-web-solutions-pvt.-ltd.\",\"https:\/\/x.com\/the_kraftors\",\"https:\/\/www.youtube.com\/@kraftorswebsolutions7410\"],\"url\":\"https:\/\/thekraftors.com\/blog\/author\/kraftors_admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Data and Schema Patches in Magento 2 - The Kraftors","description":"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/","og_locale":"en_US","og_type":"article","og_title":"Create Data and Schema Patches in Magento 2 - The Kraftors","og_description":"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.","og_url":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/","og_site_name":"The Kraftors","article_publisher":"https:\/\/www.facebook.com\/thekraftors\/","article_author":"https:\/\/www.facebook.com\/thekraftors\/","article_published_time":"2021-06-05T11:10:51+00:00","article_modified_time":"2021-06-05T19:22:03+00:00","author":"Kraftors Team","twitter_card":"summary_large_image","twitter_creator":"@the_kraftors","twitter_site":"@the_kraftors","twitter_misc":{"Written by":"Kraftors Team","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/","url":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/","name":"Create Data and Schema Patches in Magento 2 - The Kraftors","isPartOf":{"@id":"https:\/\/thekraftors.com\/blog\/#website"},"datePublished":"2021-06-05T11:10:51+00:00","dateModified":"2021-06-05T19:22:03+00:00","author":{"@id":"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/df365c3dc0480599d26a96c6969916d0"},"description":"A data patch is a class that contains data modification instructions like update, Insert, delete. A schema patch is a class that contains schema modification instructions like create, drop, alter.","breadcrumb":{"@id":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thekraftors.com\/blog\/magento2-data-schema-patch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thekraftors.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create Data and Schema Patches in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/thekraftors.com\/blog\/#website","url":"https:\/\/thekraftors.com\/blog\/","name":"The Kraftors","description":"AI | AR | eCommerce | Devops | Magento | Flutter","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thekraftors.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/df365c3dc0480599d26a96c6969916d0","name":"Kraftors Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thekraftors.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4f2f688e3509fd8078a6d7d68b748268f9e105fb8b8265685b14254ca45f2448?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4f2f688e3509fd8078a6d7d68b748268f9e105fb8b8265685b14254ca45f2448?s=96&d=mm&r=g","caption":"Kraftors Team"},"description":"At Kraftors, we offer IT Services related to development in E-Commerce Development , AI \/ ML Development, AR\/VR Development, Mobile Application Development, DevOps \/ MLOps, and Custom Development","sameAs":["http:\/\/thekraftors.com\/blog","https:\/\/www.facebook.com\/thekraftors\/","https:\/\/www.instagram.com\/the_kraftors\/","https:\/\/www.linkedin.com\/company\/kraftors-web-solutions-pvt.-ltd.","https:\/\/x.com\/the_kraftors","https:\/\/www.youtube.com\/@kraftorswebsolutions7410"],"url":"https:\/\/thekraftors.com\/blog\/author\/kraftors_admin\/"}]}},"_links":{"self":[{"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":2,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/posts\/151\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thekraftors.com\/blog\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}