forked from SolidCharity/discourse_to_flarum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate-example.yaml
144 lines (136 loc) · 4.22 KB
/
migrate-example.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#yaml-migration-config
---
authentification:
old-database:
host: localhost
name: discourse
user: discourse
password: discourse
new-database:
host: localhost
name: flarum
user: flarum
password: flarum
flarum_table_prefix: "fl_"
steps:
- action: RUN_COMMAND
enabled: true
command: DELETE FROM fl_tags WHERE id=1
- action: COPY
enabled: true
old-table: categories
new-table: fl_tags
columns:
id: id
name: name
color: color
position: position
parent_category_id: parent_id
slug: slug
description: description
- action: RUN_COMMAND
enable: true
command: UPDATE fl_tags SET parent_id = NULL WHERE parent_id = 0
- action: COPY
enabled: true
old-table: posts
new-table: fl_posts
# ignore posts by discourse system account, user_id is -1
join: ' WHERE user_id >= 0'
columns:
id: id
user_id: user_id
topic_id: discussion_id
raw*: content
created_at: time
updated_at: edit_time
- action: RUN_COMMAND
enabled: true
command: UPDATE fl_posts SET type='comment'
- action: COPY
enabled: true
old-table: topics
new-table: fl_discussions
# ignore posts by discourse system account, user_id is -1
join: ' WHERE user_id >= 0'
columns:
id: id
title: title
posts_count++: comments_count
participant_count: participants_count
created_at: start_time
user_id: start_user_id
updated_at: last_time
last_post_user_id: last_user_id
slug: slug
archetype?private_message: is_private
- action: RUN_COMMAND
enabled: true
command: DELETE FROM fl_discussions WHERE title='Backup completed successfully'
- action: FIRST_AND_LAST
enabled: true
table: fl_discussions
from-table: fl_posts
start_post_id: last_post_id
- action: COPY
enabled: true
old-table: topics
new-table: fl_discussions_tags
columns:
id: discussion_id
category_id: tag_id
- action: RUN_COMMAND
enabled: true
# make all discussions private that are in category Staff
command: UPDATE fl_discussions d SET is_private=1 WHERE EXISTS (SELECT * FROM fl_discussions_tags dt, fl_tags t where dt.discussion_id = d.id and dt.tag_id = t.id and t.name='Staff')
- action: RUN_COMMAND
enabled: true
# make all posts private that are in a private discussion
command: UPDATE fl_posts p SET is_private=1 WHERE EXISTS (SELECT * FROM fl_discussions d where d.id = p.discussion_id and d.is_private=1)
- action: RUN_COMMAND
enabled: true
# make all posts private that are from user 0 (system user in discourse) or lower
command: UPDATE fl_posts p SET is_private=1 WHERE p.user_id<=0
- action: RUN_COMMAND
enabled: true
# make all discussions private that only have private posts
command: UPDATE fl_discussions d SET is_private=1 WHERE NOT EXISTS (SELECT * from fl_posts p WHERE p.discussion_id = d.id and p.is_private=0)
- action: RUN_COMMAND
enabled: true
# update discussions count of tags
command: UPDATE fl_tags t SET t.discussions_count = (SELECT COUNT(*) FROM fl_discussions_tags dt, fl_discussions d WHERE dt.discussion_id = d.id AND dt.tag_id = t.id AND d.is_private=0)
- action: RUN_COMMAND
enabled: true
# make all tags invisible that have no public discussions
command: UPDATE fl_tags t SET is_hidden=1, is_restricted=1 WHERE t.discussions_count = 0
- action: RUN_COMMAND
enabled: true
# delete the flarum admin user. the first user from discourse will be the admin
command: DELETE FROM fl_users WHERE id=1
- action: COPY
enabled: true
old-table: users
new-table: fl_users
join: ' u, user_emails um WHERE user_id=u.id AND "primary"=true'
where: u.id > 0
orderby: u.id
columns:
u.id: id
username: username
email: email
password_hash: password
u.created_at: join_time
last_posted_at: last_seen_time
- action: RUN_COMMAND
enabled: true
command: UPDATE fl_users u SET discussions_count=(SELECT count(*) FROM fl_discussions d WHERE d.is_private=0 AND d.start_user_id=u.id)
- action: RUN_COMMAND
enabled: true
command: UPDATE fl_users u SET comments_count=(SELECT count(*) FROM fl_posts p WHERE p.is_private=0 AND p.user_id=u.id)
- action: RUN_COMMAND
enabled: true
command: DELETE FROM fl_users WHERE password='NULL'
- action: SET_PARENT_TAGS
enabled: true
from: fl_tags
into: fl_discussion_tags