-
Notifications
You must be signed in to change notification settings - Fork 3
chore: dev from dump improvement #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c5493f8
ea376a0
424bfd1
e4d2616
c05b008
85a2ba2
d9ba144
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| IGNORE_SEEDING=true | ||
| DONT_EXECUTE_TRIGGERS=true | ||
| FROM_DUMP=true | ||
| SKIP_CACHE_REBUILD=true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,4 @@ prisma-local/seeds/productionTxs.csv | |
| paybutton-config.json | ||
|
|
||
| dump.sql* | ||
| .forever | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,11 +10,25 @@ sed_vars () { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| cd /home/mysql/raw_entrypoint || exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for file in *.sql; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed_vars "$file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$file" == *dump* ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Linking dump file: $file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ln -s /home/mysql/raw_entrypoint/"$file" /home/mysql/entrypoint/"$file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Copying file $file after seding vars" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed_vars "$file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ../entrypoint/ || exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for file in *.sql; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mariadb -u root -p"$MYSQL_ROOT_PASSWORD" < "$file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$file" == *dump* ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| filesize=$(stat -Lc%s "$file" 2>/dev/null || stat -Lf%z "$file" 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Importing $file ($(numfmt --to=iec $filesize)) ..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quote Unquoted Suggested fix- echo "Importing $file ($(numfmt --to=iec $filesize)) ..."
+ echo "Importing $file ($(numfmt --to=iec "$filesize")) ..."📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[info] 27-27: Double quote to prevent globbing and word splitting. (SC2086) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| pv "$file" | mariadb -u root -p"$MYSQL_ROOT_PASSWORD" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Importing $file ..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mariadb -u root -p"$MYSQL_ROOT_PASSWORD" < "$file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Done importing $file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
24
to
34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop on import errors to avoid partial DB initialization. This loop continues even if Suggested fix+set -euo pipefail
+
for file in *.sql; do
if [[ "$file" == *dump* ]]; then
filesize=$(stat -Lc%s "$file" 2>/dev/null || stat -Lf%z "$file" 2>/dev/null)
echo "Importing $file ($(numfmt --to=iec $filesize)) ..."
- pv "$file" | mariadb -u root -p"$MYSQL_ROOT_PASSWORD"
+ pv "$file" | mariadb -u root -p"$MYSQL_ROOT_PASSWORD"
else
echo "Importing $file ..."
mariadb -u root -p"$MYSQL_ROOT_PASSWORD" < "$file"
fi
echo "Done importing $file"
done📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[info] 27-27: Double quote to prevent globbing and word splitting. (SC2086) 🤖 Prompt for AI Agents
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash
+set -euo pipefail
vars="MYSQL_USER MYSQL_PASSWORD ...One thing to watch out for with - ln -s /home/mysql/raw_entrypoint/"$file" /home/mysql/entrypoint/"$file"
+ ln -sf /home/mysql/raw_entrypoint/"$file" /home/mysql/entrypoint/"$file"The |
||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.