{"id":56197,"date":"2022-12-26T12:56:05","date_gmt":"2022-12-26T07:26:05","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56197"},"modified":"2023-07-12T16:08:00","modified_gmt":"2023-07-12T10:38:00","slug":"custom-table-migration-from-drupal-7-to-8","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/custom-table-migration-from-drupal-7-to-8\/","title":{"rendered":"Custom table migration from Drupal 7 to 8"},"content":{"rendered":"<p>Custom table migration is slightly different from Content migration. We can migrate Custom table data from Drupal 7 to 8 by using simple steps. Before discussing those steps, we should know which modules are necessary to migrate data.<\/p>\n<p><strong>Necessary modules<\/strong><\/p>\n<ol>\n<li>Migrate<\/li>\n<li>Migrate Drupal<\/li>\n<li>Migrate Drupal UI<\/li>\n<li>Migrate Plus<\/li>\n<li>Migrate Tools<\/li>\n<li>Drupal Upgrade<\/li>\n<\/ol>\n<p>We can use these modules according to our requirements, a few more modules are also available for migration. So, let&#8217;s get back to the custom module migration. Let&#8217;s create a directory (Custom Table Migration) under our migration directory.<\/p>\n<p>The structure will look like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56265\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Screenshot-from-2022-12-25-20-03-532.png\" alt=\"\" width=\"608\" height=\"284\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Screenshot-from-2022-12-25-20-03-532.png 608w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Screenshot-from-2022-12-25-20-03-532-300x140.png 300w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><\/p>\n<p>In the Custom Table Migration directory, we will create <strong>config &amp; src <\/strong>directory with one yml file <strong>custom_table_migration.info.yml<\/strong><\/p>\n<p>In the <strong>custom_table_migration.info.yml <\/strong>file, we write our code like.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56194\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/info-file-1.jpg\" alt=\"\" width=\"776\" height=\"154\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/info-file-1.jpg 776w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/info-file-1-300x60.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/info-file-1-768x152.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/info-file-1-624x124.jpg 624w\" sizes=\"(max-width: 776px) 100vw, 776px\" \/><\/p>\n<p>Now we need to create the main configuration file.<\/p>\n<p><span class=\"geshifilter\"><code class=\"text geshifilter-text\">modules\/custom_migration\/custom_table_migration\/config\/install\/migrate_plus.migration.d7_custom_school_migrate.yml<\/code><\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56195\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document1.jpg\" alt=\"\" width=\"774\" height=\"1018\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document1.jpg 774w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document1-228x300.jpg 228w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document1-768x1010.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document1-624x821.jpg 624w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/p>\n<p>In the <strong>Destination<\/strong> section, we need to define <em>plugin:<\/em>\u00a0<strong>table<\/strong> and <em>table_name<\/em> : <strong>custom_school_data<\/strong><\/p>\n<p>Now we will create a file for our Source Plugin. In this file, we need to implement both the <strong>query()\u00a0<\/strong>and <strong>prepareRow() <\/strong>methods.<\/p>\n<p><span class=\"geshifilter\"><code class=\"text geshifilter-text\">modules\/custom_migration\/custom_table_migration\/src\/Plugin\/migrate\/source\/CustomSchoolData.php<\/code><\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56196\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-scaled.jpg\" alt=\"\" width=\"1438\" height=\"2560\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-scaled.jpg 1438w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-169x300.jpg 169w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-575x1024.jpg 575w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-768x1367.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-863x1536.jpg 863w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-1151x2048.jpg 1151w, \/blog\/wp-ttn-blog\/uploads\/2022\/12\/Merged_document3-624x1111.jpg 624w\" sizes=\"(max-width: 1438px) 100vw, 1438px\" \/><\/p>\n<p>In our case, we check whether the id is migrated or not if migrated, then we skip that data row.<\/p>\n<p>So this is a simple example of custom table migration.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Custom table migration is slightly different from Content migration. We can migrate Custom table data from Drupal 7 to 8 by using simple steps. Before discussing those steps, we should know which modules are necessary to migrate data. Necessary modules Migrate Migrate Drupal Migrate Drupal UI Migrate Plus Migrate Tools Drupal Upgrade We can use [&hellip;]<\/p>\n","protected":false},"author":1527,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":14},"categories":[3602],"tags":[5066,3601,4884],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56197"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1527"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56197"}],"version-history":[{"count":5,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56197\/revisions"}],"predecessor-version":[{"id":57759,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56197\/revisions\/57759"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}