ORIENT/scripts/post.sql

43 lines
2.7 KiB
SQL

DELETE from orient_wordpress.arient_ru_posts where post_type not in ('post','attachment');
DELETE from orient_wordpress.arient_ru_posts where post_status in ('draft','auto-draft');
ALTER TABLE `rainlab_blog_posts` CHANGE `title` `title` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `slug` `slug` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
INSERT INTO orient.rainlab_blog_posts (user_id,title,slug,excerpt,content_html,published_at,published,created_at,updated_at,locale,id_en)
SELECT post_author,post_title,post_name,post_excerpt,post_content,post_date,1,post_date,post_modified,'en',id from orient_wordpress.arient_2_posts;
INSERT INTO orient.rainlab_blog_posts (user_id,title,slug,excerpt,content,content_html,published_at,published,created_at,updated_at,locale,id_en)
SELECT post_author,post_title,post_name,post_excerpt,post_content,post_content,post_date,1,post_date,post_modified,'ru',id
from orient_wordpress.arient_ru_posts where post_type='post' and post_status='publish';
UPDATE rainlab_blog_posts SET powerseo_title = title, powerseo_description = excerpt, powerseo_robot_index = 'index', powerseo_robot_follow = 'nofollow';
//////// angliski postlarda 2019dan ashakdaky materiallar pozulan
Delete FROM arient_2_posts_temp WHERE post_date <'2019-01-01'
////////////////////////////////insert featured images
UPDATE rainlab_blog_posts rb
inner join iatm_2_postmeta ip on rb.id_en = ip.post_id and ip.meta_key='_thumbnail_id'
inner join arient_2_posts_temp wp on wp.ID = ip.meta_value
set rb.featerd_image = wp.guid
ALTER TABLE `rainlab_blog_posts` CHANGE `featured_image` `featured_image` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;
UPDATE rainlab_blog_posts rb
inner join orient_wordpress.iatm_orient_postmeta ip on rb.id_ru = ip.post_id and ip.meta_key='_thumbnail_id'
inner join orient_wordpress.arient_ru_posts wp on wp.ID = ip.meta_value
set rb.featured_image = REPLACE(wp.guid,'https://orient.tm/en/wp-content/','')
////////////// replace image address
UPDATE rainlab_blog_posts set featured_image = REPLACE(featured_image,'https://orient.tm/en/wp-content/','') where featured_image !=''
///////////////////////post views//////
INSERT INTO orient.vdomah_blogviews_views (views,post_id)
select pp.pageviews,rb.id FROM orient_wordpress.iatm_orient_2_popularpostsdata pp
INNER join orient.rainlab_blog_posts rb on rb.id_en = pp.postid
INSERT INTO orient.vdomah_blogviews_views (views,post_id)
select pp.pageviews,rb.id FROM orient_wordpress.iatm_orient_popularpostsdata pp
INNER join orient.rainlab_blog_posts rb on rb.id_ru = pp.postid AND rb.locale = 'ru'