Skip to content

Commit

Permalink
taskfile: create-db via taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nhdzhra committed Oct 25, 2024
1 parent e9bccc7 commit 7451b5d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions infra/tools/taskfile/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,29 @@ tasks:
- for: { var: NAMESPACE }
cmd: helm ls -n {{.ITEM}} | grep "\-dev" | awk '{ print $1 }' | xargs -I % helm delete -n {{.ITEM}} % 2> /dev/null
ignore_error: true

create-mysql-db:
desc: Create a MySQL DB
ignore_error: true
cmds:
- |
mysql -h ${MYSQL_DEV_HOST} -u root -p${MYSQL_DEV_PASSWORD} -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME};
CREATE USER IF NOT EXISTS '${APP_NAME}'@'%' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${APP_NAME}'@'%';
FLUSH PRIVILEGES;" 2> /dev/null
create-pgsql-db:
desc: "Create a PostgreSQL DB"
ignore_error: true
cmds:
- psql -h ${PGSQL_DEV_HOST} -U postgres -c "CREATE DATABASE ${DB_NAME};" 2> /dev/null
- psql -h ${PGSQL_DEV_HOST} -U postgres -c "CREATE USER ${APP_NAME} WITH PASSWORD '${DB_PASSWORD}';" 2> /dev/null
- psql -h ${PGSQL_DEV_HOST} -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${APP_NAME};" 2> /dev/null

# drop-mysql-db:
# desc: Drop MySQL DB
# cmd:

# drop-postgres-db:
# desc: Drop Postgres DB
# cmd:

0 comments on commit 7451b5d

Please sign in to comment.