Skip to content
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

feat(infra): update destroy db weekly #173

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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