Last active
October 7, 2017 08:28
-
-
Save lepinekong/8dcaa9dc77682da51b404876052a760d to your computer and use it in GitHub Desktop.
Rebolview (http://www.rebol.com/downloads.html) scripts for migrating wordpress mu to new domain name with phpmyadmin (no SSH access needed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; =================================================== | |
;; this is used by new-blog.r to output list of blogs in blogs.txt | |
;; =================================================== | |
rebol[] | |
sql_file_rootname: "<#sql-file-rootname#>" | |
domainname: "<#domain-name#>" | |
db_prefix: "<#db-prefix#>" | |
'============================= | |
blogs: load %blogs.txt | |
template: {UPDATE `<%db_prefix%><%blogid%>_options` SET `option_value` = 'https://<%domainname%>/<%blogname%>' WHERE `<%db_prefix%><%blogid%>_options`.`option_id` = 1; | |
UPDATE `<%db_prefix%><%blogid%>_options` SET `option_value` = 'https://<%domainname%>/<%blogname%>' WHERE `<%db_prefix%><%blogid%>_options`.`option_id` = 2;} | |
sql-queries: build-markup "UPDATE `<%db_prefix%>blogs` SET `domain` = '<%domainname%>';" | |
append sql-queries newline | |
append sql-queries build-markup { | |
UPDATE `<%db_prefix%>options` SET `option_value` = 'https://<%domainname%>' WHERE `<%db_prefix%>options`.`option_id` = 1; | |
UPDATE `<%db_prefix%>options` SET `option_value` = 'https://<%domainname%>' WHERE `<%db_prefix%>options`.`option_id` = 2; | |
} | |
append sql-queries newline | |
append sql-queries build-markup {UPDATE `<%db_prefix%>site` SET `domain` = '<%domainname%>' WHERE `<%db_prefix%>site`.`id` = 1;} | |
append sql-queries newline | |
append sql-queries build-markup {UPDATE `<%db_prefix%>sitemeta` SET `meta_value` = 'https://<%domainname%>/' WHERE `<%db_prefix%>sitemeta`.`meta_id` = 14;} | |
append sql-queries newline | |
foreach [id blog] skip blogs 2 [ | |
blogid: id | |
blogname: blog | |
print blogid | |
print blogname | |
append sql-queries build-markup template | |
append sql-queries newline | |
append sql-queries newline | |
] | |
write to-rebol-file rejoin [sql_file_rootname ".sql"] sql-queries | |
write clipboard:// sql-queries | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; =================================================== | |
;; this is used to generate migration script see | |
;; for example softwaretestingmonitor.stream | |
;; =================================================== | |
rebol[] | |
domain-name: ask "domain-name: " | |
sql-file-rootname: ask "sql-file-rootname: " | |
db-prefix: ask "db-prefix: " | |
template: read %blog-template.r.tpl | |
old-build-markup: :build-markup | |
build-markup: func [ | |
{Return markup text replacing <%tags%> with their evaluated results.} | |
content [string! file! url!] | |
/quiet "Do not show errors in the output." | |
/local out eval value | |
][ | |
content: either string? content [copy content] [read content] | |
out: make string! 126 | |
eval: func [val /local tmp] [ | |
either error? set/any 'tmp try [do val] [ | |
if not quiet [ | |
tmp: disarm :tmp | |
append out reform ["***ERROR" tmp/id "in:" val] | |
] | |
] [ | |
if not unset? get/any 'tmp [append out :tmp] | |
] | |
] | |
parse/all content [ | |
any [ | |
end break | |
| "<#" [copy value to "#>" 2 skip | copy value to end] (eval value) | |
| copy value [to "<#" | to end] (append out value) | |
] | |
] | |
out | |
] | |
source: build-markup template | |
write to-rebol-file rejoin [sql-file-rootname ".r"] source | |
build-markup: :old-build-markup | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; =================================================== | |
;; this is used to parse blogs.csv | |
;; exported from mysql xxx_blogs table with phpmyadmin | |
;; =================================================== | |
rebol[] | |
do %csv-tools.r ; see https://gist.github.com/lepinekong/36c81cc28b25d59a051563bd398842e9 | |
raw-blogs: load-csv %blogs.csv | |
blogs: [] | |
foreach blog raw-blogs [append blogs blog/1 append blogs (pick (parse blog/4 "/") 2)] | |
write %blogs.txt mold blogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; =================================================== | |
;; this is an example of script generated by new-blog.r | |
;; this script will generate sql commands to paste into phpmyadmin | |
;; phpmyadmin may refuse to execute more than 5O lines | |
;; in that case just execute every 50 lines commands | |
;; in the end don't forget to change domain in wp-config.php | |
;; =================================================== | |
rebol[] | |
sql_file_rootname: "softwaretestingmonitor" | |
domainname: "softwaretestingmonitor.stream" | |
db_prefix: "wp_" | |
'============================= | |
blogs: load %blogs.txt | |
template: {UPDATE `<%db_prefix%><%blogid%>_options` SET `option_value` = 'https://<%domainname%>/<%blogname%>' WHERE `<%db_prefix%><%blogid%>_options`.`option_id` = 1; | |
UPDATE `<%db_prefix%><%blogid%>_options` SET `option_value` = 'https://<%domainname%>/<%blogname%>' WHERE `<%db_prefix%><%blogid%>_options`.`option_id` = 2;} | |
sql-queries: build-markup "UPDATE `<%db_prefix%>blogs` SET `domain` = '<%domainname%>';" | |
append sql-queries newline | |
append sql-queries build-markup { | |
UPDATE `<%db_prefix%>options` SET `option_value` = 'https://<%domainname%>' WHERE `<%db_prefix%>options`.`option_id` = 1; | |
UPDATE `<%db_prefix%>options` SET `option_value` = 'https://<%domainname%>' WHERE `<%db_prefix%>options`.`option_id` = 2; | |
} | |
append sql-queries newline | |
append sql-queries build-markup {UPDATE `<%db_prefix%>site` SET `domain` = '<%domainname%>' WHERE `<%db_prefix%>site`.`id` = 1;} | |
append sql-queries newline | |
append sql-queries build-markup {UPDATE `<%db_prefix%>sitemeta` SET `meta_value` = 'https://<%domainname%>/' WHERE `<%db_prefix%>sitemeta`.`meta_id` = 14;} | |
append sql-queries newline | |
foreach [id blog] skip blogs 2 [ | |
blogid: id | |
blogname: blog | |
append sql-queries build-markup template | |
append sql-queries newline | |
append sql-queries newline | |
] | |
write to-rebol-file rejoin [sql_file_rootname ".sql"] sql-queries | |
write clipboard:// sql-queries | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment