Skip to content

Commit

Permalink
ci(workflows): add github action for deleting data from remote database
Browse files Browse the repository at this point in the history
  ## what
  - add github action for deleting data from remote database
    - install `psql` client
    - delete the data on table `activities`
    - reset auto increment for `activities.id` to 1

  ## how

  ## why
  - the database is being used by public with limited space
    - don't want to go overboard in using the database

  ## where
  - ./.github/workflows/remoteDatabaseReset.yaml

  ## usage

  ## commit id, issue or pull request

  ## notes
  • Loading branch information
Clumsy-Coder committed Nov 4, 2024
1 parent b66c3b0 commit ded9c93
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/remoteDatabaseReset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Delete data from remote database
on: push

# - https://stackoverflow.com/a/64697047/3053548

jobs:
psql:
runs-on: ubuntu-latest
container: ubuntu
steps:
- name: install psql client
run: |
apt-get update
apt-get install --yes --no-install-recommends postgresql-client
- name: delete data from remote database and reset auto increment
run: |
psql "$CONNECTION_STRING" -c "DELETE FROM activities;"
env:
CONNECTION_STRING: ${{secrets.REMOTE_POSTGRES_CONNECTION_STRING }}

- name: reset auto increment
run: |
psql "$CONNECTION_STRING" -c "ALTER SEQUENCE public.activities_id_seq RESTART 1;"
env:
CONNECTION_STRING: ${{secrets.REMOTE_POSTGRES_CONNECTION_STRING }}

0 comments on commit ded9c93

Please sign in to comment.