forked from ec-europa/joinup-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.migration.xml
More file actions
214 lines (203 loc) · 9.17 KB
/
build.migration.xml
File metadata and controls
214 lines (203 loc) · 9.17 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Joinup migration" default="help">
<target name="disable-solr-index"
description="Disable immediate indexing in Solr index.">
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>search_api.index.published</param>
<param>options.index_directly 0</param>
</drush>
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>search_api.index.unpublished</param>
<param>options.index_directly 0</param>
</drush>
</target>
<!-- Run the migration IDs specified in the configuration. -->
<target name="run-migrations"
description="Run the migrations."
depends="enable-migration-modules, disable-solr-index">
<echo message="Running migration IDs" />
<drush
command="sql-query"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<option name="database" value="migrate" />
<param>"UPDATE users SET status = 1 WHERE uid = 6364"</param>
</drush>
<drush
command="migrate-import"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<option name="all" />
<option name="feedback" value="1000" />
<option name="force" />
<option name="timestamp" />
</drush>
<!-- If a migration crashes, it's possible that the system mailer is not
restored. Thus we are forcing the restore of system mailer. -->
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>system.mail</param>
<param>interface.default</param>
<param>php_mail</param>
</drush>
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>mailsystem.settings</param>
<param>defaults.sender</param>
<param>swiftmailer</param>
</drush>
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>search_api.index.published</param>
<param>options.index_directly 1</param>
</drush>
<drush
command="cset"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>search_api.index.unpublished</param>
<param>options.index_directly 1</param>
</drush>
<drush
command="sapi-i"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<option name="batch-size" value="50" />
</drush>
</target>
<target name="import-legacy-db"
description="Import the legacy D6 database."
depends="create-d6-db">
<pdosqlexec url="${migration.db.type}:host=${migration.db.host};dbname=${migration.db.name}"
userid="${migration.db.user}"
password="${migration.db.password}">
<transaction src="${migration.db.import_path}"/>
</pdosqlexec>
<if>
<available file="${migration.db.views_import_path}" type="file" property="migrate.views_file_exists" value="true"/>
<then>
<pdosqlexec url="${migration.db.type}:host=${migration.db.host};dbname=${migration.db.name}"
userid="${migration.db.user}"
password="${migration.db.password}">
<transaction src="${migration.db.views_import_path}"/>
</pdosqlexec>
</then>
</if>
<!--
The 'd8_solution' MySQL view has been fixed in post update script
joinup_migrate_post_update_more_redirects() but on UAT, we use a
not-fixed legacy D6 database. Because this 'post update' was already
executed on the current PRODUCTION snapshot, it will not be executed
again, meaning the view is still not fixed, so we have to fix it.
@see joinup_migrate_post_update_more_redirects()
-->
<pdosqlexec url="${migration.db.type}:host=${migration.db.host};dbname=${migration.db.name}"
userid="${migration.db.user}"
password="${migration.db.password}">
<transaction src="web/modules/custom/joinup_migrate/fixture/0.solution.sql"/>
</pdosqlexec>
</target>
<!-- Add migration settings to Drupal settings file. -->
<target name="setup-migration"
description="Initial setup to prepare the build for migration. Only needs to be run once."
depends="writable-settings-php">
<echo message="Setup migration" />
<append destFile="${website.settings.php}" text="${line.separator}$databases['migrate']['default'] = [${line.separator}
'database' => '${migration.db.name}',${line.separator}
'username' => '${migration.db.user}',${line.separator}
'password' => '${migration.db.password}',${line.separator}
'prefix' => '${migration.db.prefix}',${line.separator}
'host' => '${migration.db.host}',${line.separator}
'port' => '${migration.db.port}',${line.separator}
'namespace' => 'Drupal\\Core\\Database\\Driver\\${migration.db.type}',${line.separator}
'driver' => '${migration.db.type}',${line.separator}
// We set the timezone to UTC to force MySQL time functions to correctly${line.separator}
// convert timestamps into date/time.${line.separator}
'init_commands' => [${line.separator}
'set_timezone_to_utc' => "SET time_zone='+00:00';",${line.separator}
],${line.separator}];${line.separator}" />
<append destFile="${website.settings.php}" text="$settings['joinup_migrate.mode'] = '${migration.mode}';${line.separator}" />
<append destFile="${website.settings.php}" text="$settings['joinup_migrate.mock_filesystem'] = ${migration.mock_filesystem};${line.separator}" />
<append destFile="${website.settings.php}" text="$settings['joinup_migrate.source.files'] = '${migration.source.files}';${line.separator}" />
</target>
<!-- Enable migration modules. -->
<target name="enable-migration-modules">
<drush
command="pm-enable"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}"
verbose="${drush.verbose}">
<param>${migration.modules}</param>
</drush>
</target>
<target name="create-d6-db">
<pdosqlexec url="${migration.db.type}:host=${migration.db.host}" userid="${migration.db.user}" password="${migration.db.password}">
DROP DATABASE IF EXISTS ${migration.db.name};
</pdosqlexec>
<pdosqlexec url="${migration.db.type}:host=${migration.db.host}" userid="${migration.db.user}" password="${migration.db.password}">
CREATE DATABASE ${migration.db.name};
</pdosqlexec>
</target>
<!-- Import the legacy database testing data -->
<target name="import-legacy-test-db"
description="Import the legacy D6 testing database."
depends="create-d6-test-db">
<pdosqlexec
url="${drupal.db.type}:host=${drupal.db.host};dbname=${phpunit.migrate.legacy_db.name}"
userid="${drupal.db.user}"
password="${drupal.db.password}">
<transaction src="resources/migrate/d6-joinup-test.sql"/>
</pdosqlexec>
</target>
<target name="acceptance-migration"
description="Wrapper around execute-migration that gets executed only when the related property is set."
if="migration.acceptance">
<phingcall target="execute-migration" />
</target>
<target
name="execute-migration"
description="Configure and import the migration database, run the migration tasks."
depends="setup-migration, import-legacy-db, run-migrations" />
<!-- Create the legacy testing database -->
<target name="create-d6-test-db">
<pdosqlexec url="${drupal.db.type}:host=${drupal.db.host}"
userid="${drupal.db.user}" password="${drupal.db.password}">
DROP DATABASE IF EXISTS ${phpunit.migrate.legacy_db.name};
</pdosqlexec>
<pdosqlexec url="${drupal.db.type}:host=${drupal.db.host}"
userid="${drupal.db.user}" password="${drupal.db.password}">
CREATE DATABASE ${phpunit.migrate.legacy_db.name};
</pdosqlexec>
</target>
</project>