From 60b0cf6514e67e8e8a981dbe4410b322b045b68d Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Mon, 22 Aug 2022 09:09:40 -0300 Subject: [PATCH] feat: add migration --- src/migrations.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/migrations.php b/src/migrations.php index d764b1dc0..2434fab0d 100644 --- a/src/migrations.php +++ b/src/migrations.php @@ -480,6 +480,23 @@ class Migrations { } } + static function insert_meta_default_metadata_section() { + global $wpdb; + // create metadata + $wpdb->query( + $wpdb->prepare( + "INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) + SELECT ID,'metadata_section_id', %s FROM $wpdb->posts + WHERE post_type = %s AND ID NOT IN ( + SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s + )" + ,\Tainacan\Entities\Metadata_Section::$default_section_slug + ,\Tainacan\Entities\Metadatum::$post_type + ,\Tainacan\Entities\Metadata_Section::$default_section_slug + ) + ); + } + }