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
47707ce3
Verified
Commit
47707ce3
authored
3 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
FIX password and force dt_maj not null
parent
62d491bc
No related branches found
No related tags found
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
+16
-7
16 additions, 7 deletions
tools/migrations/migrate_from_symfony_3_to_5.sh
with
16 additions
and
7 deletions
tools/migrations/migrate_from_symfony_3_to_5.sh
+
16
−
7
View file @
47707ce3
...
@@ -21,11 +21,23 @@ if [ "$backup" -ne 0 ]; then
...
@@ -21,11 +21,23 @@ if [ "$backup" -ne 0 ]; then
docker-compose
exec
mysql mysqldump
-u
root
-p
$MYSQL_ROOT_PASSWORD
$MYSQL_DATABASE
|
\
docker-compose
exec
mysql mysqldump
-u
root
-p
$MYSQL_ROOT_PASSWORD
$MYSQL_DATABASE
|
\
grep
-v
Warning |
grep
-v
Warning |
docker
exec
-i
$(
docker-compose ps
-q
mysql
)
mysql
-u
root
-p
$MYSQL_ROOT_PASSWORD
$BACKUP_DB
docker
exec
-i
$(
docker-compose ps
-q
mysql
)
mysql
-u
root
-p
$MYSQL_ROOT_PASSWORD
$BACKUP_DB
ret
=
$?
if
[
$ret
-ne
0
]
;
then
echo
"Backup failed, aborting"
exit
$ret
fi
echo
"Backup done"
echo
"Backup done"
else
else
echo
"A previous backup exists, skipping backup step"
echo
"A previous backup exists, skipping backup step"
fi
fi
echo
-e
"Please check the integrity of the backup databse
$BACKUP_DB
then type 'yes' to continue.
\n
The next step will erase your database if the backup is incomplete you WILL LOOSE ALL YOUR DATA
\n
"
read
next
if
[
"
$next
"
!=
'yes'
]
;
then
echo
"Aborting as you did not type yes"
exit
1
fi
#
#
# Step 2 Reload db with initial data
# Step 2 Reload db with initial data
#
#
...
@@ -38,9 +50,9 @@ docker-compose exec memorekall-member composer reload-db
...
@@ -38,9 +50,9 @@ docker-compose exec memorekall-member composer reload-db
# Columns renaming in the form pattern/replacement/sedopts
# Columns renaming in the form pattern/replacement/sedopts
declare
-A
COLUMNS_REPLACEMENTS
declare
-A
COLUMNS_REPLACEMENTS
COLUMNS_REPLACEMENTS[user]
=
'
credential_expired/credentials_expired as credential_expired/
'
COLUMNS_REPLACEMENTS[user]
=
"roles,
\(
.*
\)
credential_expired/
'[
\"
USER_ROLE
\"
]' as roles,
\1
credentials_expired as credential_expired/
"
# Old capsule table does not have a password field
# Old capsule table does not have a password field
COLUMNS_REPLACEMENTS[capsule]
=
'password/
NULL
as password/'
COLUMNS_REPLACEMENTS[capsule]
=
'password/
SUBSTRING(edition_link, -40)
as password/'
TABLES
=
"user reset_password_request capsule doctrine_migration_versions editeur_capsule"
TABLES
=
"user reset_password_request capsule doctrine_migration_versions editeur_capsule"
echo
"SET foreign_key_checks = 0;"
>
$$
.sql
echo
"SET foreign_key_checks = 0;"
>
$$
.sql
...
@@ -57,12 +69,9 @@ for table in $TABLES; do
...
@@ -57,12 +69,9 @@ for table in $TABLES; do
echo
"DELETE FROM
$MYSQL_DATABASE
.
$table
;"
>>
$$
.sql
echo
"DELETE FROM
$MYSQL_DATABASE
.
$table
;"
>>
$$
.sql
echo
"INSERT INTO
$MYSQL_DATABASE
.
$table
(
$COLUMNS
) SELECT
$COLUMNS_OLD
FROM
$BACKUP_DB
.
$table
;"
>>
$$
.sql
echo
"INSERT INTO
$MYSQL_DATABASE
.
$table
(
$COLUMNS
) SELECT
$COLUMNS_OLD
FROM
$BACKUP_DB
.
$table
;"
>>
$$
.sql
done
done
# Ensure that dt_maj is not NULL
echo
"UPDATE
$MYSQL_DATABASE
.capsule SET dt_maj=dt_crea WHERE dt_maj IS NULL;"
>>
$$
.sql
echo
"SET foreign_key_checks = 1;"
>>
$$
.sql
echo
"SET foreign_key_checks = 1;"
>>
$$
.sql
cat
$$
.sql | docker
exec
-i
$(
docker-compose ps
-q
mysql
)
mysql
-u
root
-p
$MYSQL_ROOT_PASSWORD
cat
$$
.sql | docker
exec
-i
$(
docker-compose ps
-q
mysql
)
mysql
-u
root
-p
$MYSQL_ROOT_PASSWORD
echo
"All done"
echo
"All done"
rm
$$
.sql
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