Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-operations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal
paas
drupal-operations
Commits
69a037f2
Commit
69a037f2
authored
3 years ago
by
Konstantinos Samaras-Tsakiris
Browse files
Options
Downloads
Patches
Plain Diff
Log progress
parent
4be6671c
No related branches found
No related tags found
1 merge request
!18
Fix primary key auto increment
Pipeline
#3740705
failed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/admin/auto-increment/reset-auto-increment_all-sites.sh
+11
-4
11 additions, 4 deletions
...ts/admin/auto-increment/reset-auto-increment_all-sites.sh
with
11 additions
and
4 deletions
scripts/admin/auto-increment/reset-auto-increment_all-sites.sh
+
11
−
4
View file @
69a037f2
#!/bin/bash
#!/bin/bash
# This script fixes issue https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/885
# It accesses the database of every website, iterates over a list of tables,
# and for each {website,table} it resets the auto_increment
# which broke after the first Drupal 9.3 upgrade.
PATH
=
"
$PATH
:~/k8s-migrate/"
# 1. Get all the DB credentials
# 1. Get all the DB credentials
# Decode them
# Decode them
# And store them in a single line each in a file. Each line is a JSON for a single site.
# And store them in a single line each in a file. Each line is a JSON for a single site.
#
oc get -o json secret -l dbcredentials -A | \
oc get
-o
json secret
-l
dbcredentials
-A
|
\
#
jq -r '.items[] | .data[] |= @base64d | {"name": (.metadata.namespace + .metadata.name), "data": .data}' | \
jq
-r
'.items[] | .data[] |= @base64d | {"name": (.metadata.namespace + .metadata.name), "data": .data}'
|
\
#
jq -r -c '{"name":.name} + {"data": (.data | to_entries | map(("export "+.key+"="+.value)))}' > secrets.json
jq
-r
-c
'{"name":.name} + {"data": (.data | to_entries | map(("export "+.key+"="+.value)))}'
>
secrets.json
# 2. Create a DB env file for each site
# 2. Create a DB env file for each site
...
@@ -23,7 +30,6 @@ while IFS= read -r siteJSON; do
...
@@ -23,7 +30,6 @@ while IFS= read -r siteJSON; do
done
< secrets.json
done
< secrets.json
# 3. Perform the operation for each DB
# 3. Perform the operation for each DB
# reset-auto-increment.sh
TABLES_FILE
=
"
`
dirname
$0
`
/tables-primarykey"
TABLES_FILE
=
"
`
dirname
$0
`
/tables-primarykey"
...
@@ -42,6 +48,7 @@ reset_table(){
...
@@ -42,6 +48,7 @@ reset_table(){
export
-f
reset_table
export
-f
reset_table
for
site
in
`
ls
sites
`
;
do
for
site
in
`
ls
sites
`
;
do
echo
">
$site
"
|
tee
-a
"
`
basename
$0
`
.log"
.
"sites/
$site
"
.
"sites/
$site
"
cat
"
$TABLES_FILE
"
| xargs
-L1
bash
-c
'reset_table $1'
cat
"
$TABLES_FILE
"
| xargs
-L1
bash
-c
'reset_table $1'
done
done
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