Skip to content

Commit

Permalink
feat(infra): update destroy db weekly (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhdzhra authored Nov 12, 2024
1 parent ebc7f29 commit 7c20c74
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions infra/tools/taskfile/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ vars:
NAMESPACE:
sh: kubectl get ns | grep -v -e maxwell -e NAME -e slack-devbot-helper | awk '{ print $1 }'

env:
APP_NAME:
sh: make get-app-name

tasks:
destroy-dev:
desc: Destroy dev
Expand All @@ -21,6 +17,9 @@ tasks:
create-mysql-db:
desc: Create a MySQL DB
ignore_error: true
env:
APP_NAME:
sh: make get-app-name
cmds:
- |
mysql -h ${LOGIN_DB_HOST} -u root -p${LOGIN_DB_PASSWORD} -e "CREATE DATABASE IF NOT EXISTS ${APP_NAME}_${DB_NAME};
Expand All @@ -32,6 +31,8 @@ tasks:
ignore_error: true
env:
PGPASSWORD: '{{.LOGIN_DB_PASSWORD}}'
APP_NAME:
sh: make get-app-name
cmds:
- |
#!/bin/bash
Expand All @@ -48,6 +49,8 @@ tasks:
ignore_error: true
env:
PGPASSWORD: '{{.LOGIN_DB_PASSWORD}}'
APP_NAME:
sh: make get-app-name
cmds:
- |
#!/bin/bash
Expand All @@ -58,6 +61,9 @@ tasks:
delete-mysql-db:
desc: "Delete a Single Mysql DB"
ignore_error: true
env:
APP_NAME:
sh: make get-app-name
cmds:
- |
#!/bin/bash
Expand All @@ -73,6 +79,7 @@ tasks:
- |
#!/bin/bash
databases=$(mysql -h ${LOGIN_DB_HOST} -u root -p${LOGIN_DB_PASSWORD} -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|mysql|sys)")
# Loop through each database and drop it
for db in $databases; do
echo "Dropping database: $db"
Expand Down

0 comments on commit 7c20c74

Please sign in to comment.