Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Memorekall Member New
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rekall
Memorekall Member New
Commits
62d491bc
Verified
Commit
62d491bc
authored
3 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Migration script from symfony 3 to 5
parent
b83dfbfd
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!46
Tuleap 88 db migration
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/migrations/migrate_from_symfony_3_to_5.sh
+23
-13
23 additions, 13 deletions
tools/migrations/migrate_from_symfony_3_to_5.sh
with
23 additions
and
13 deletions
tools/migrations/migrate_from_symfony_3_to_5.sh
+
23
−
13
View file @
62d491bc
...
...
@@ -33,26 +33,36 @@ fi
docker-compose
exec
memorekall-member composer reload-db
#
# Step 3
r
em
ove artifact
data and copy data from backup
table
# Step 3 em
pty the newly generated
data
base
and
re
copy data from
the
backup
#
echo
"Droping fixture capsule"
$mysql_cmd
$MYSQL_DATABASE
-e
"delete from capsule"
echo
"Done"
echo
"Droping fixture users"
$mysql_cmd
$MYSQL_DATABASE
-e
"delete from user"
echo
"Done"
# Columns renaming in the form pattern/replacement/sedopts
declare
-A
COLUMNS_REPLACEMENTS
COLUMNS_REPLACEMENTS[user]
=
'credential_expired/credentials_expired as credential_expired/'
# Old capsule table does not have a password field
COLUMNS_REPLACEMENTS[capsule]
=
'password/NULL as password/'
TABLES
=
"user reset_password_request capsule capsuleGroup capsules_groups doctrine_migration_versions editeur_capsule invitation_editeur_capsule"
TABLES
=
"user reset_password_request capsule doctrine_migration_versions editeur_capsule"
echo
"SET foreign_key_checks = 0;"
>
$$
.sql
for
table
in
$TABLES
;
do
echo
"Reloading table
$table
"
COLUMNS
=
$(
$mysql_cmd
--batch
--disable-column-names
\
-e
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '
$table
' AND TABLE_SCHEMA='
$MYSQL_DATABASE
'"
|
\
grep
-v
"Warning"
|
tr
'\r\n'
', '
|
sed
's/, $//'
)
#echo $COLUMNS
# TODO : what should we do about columns with name mismatch ex user.credential_expired ?
$mysql_cmd
-e
"INSERT INTO
$MYSQL_DATABASE
.
$table
SELECT
$COLUMNS
FROM
$BACKUP_DB
.
$table
;"
echo
"done"
if
[
!
-z
"
${
COLUMNS_REPLACEMENTS
[
$table
]
}
"
]
;
then
COLUMNS_OLD
=
$(
echo
$COLUMNS
|
sed
"s/
${
COLUMNS_REPLACEMENTS
[
$table
]
}
"
)
else
COLUMNS_OLD
=
$COLUMNS
fi
echo
"DELETE FROM
$MYSQL_DATABASE
.
$table
;"
>>
$$
.sql
echo
"INSERT INTO
$MYSQL_DATABASE
.
$table
(
$COLUMNS
) SELECT
$COLUMNS_OLD
FROM
$BACKUP_DB
.
$table
;"
>>
$$
.sql
done
echo
"SET foreign_key_checks = 1;"
>>
$$
.sql
cat
$$
.sql | docker
exec
-i
$(
docker-compose ps
-q
mysql
)
mysql
-u
root
-p
$MYSQL_ROOT_PASSWORD
echo
"All done"
rm
$$
.sql
#
# Step 4 Ensure entity are stored in JSON format and not array
#
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment