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

💚 Fix SQL script to clear DB #536

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
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: 0 additions & 15 deletions .github/scripts/clear-user-data-from-db.sql
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
BEGIN TRANSACTION;
GO;

DELETE FROM [dbo].[response];
GO;

DELETE FROM [dbo].[submission];
GO;

DELETE FROM [dbo].[question];
GO;

DELETE FROM [dbo].[answer];
GO;

DELETE FROM [dbo].[signin];
GO;

DELETE FROM [dbo].[user];
GO;

DELETE FROM [dbo].[establishment];
GO;

COMMIT;
GO;
27 changes: 12 additions & 15 deletions .github/workflows/clear-user-data-from-db.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
name: Clear user data from DB

on:
workflow_dispatch:
inputs:
environment:
description: "What environment to clear"
required: true
type: environment

env:
DOTNET_VERSION: ${{ vars.DOTNET_VERSION }}
type: choice
options:
- development
- tst
- staging

jobs:
disallow-prod-message:
if: inputs.environment == 'Production'
name: Disallow production message
runs-on: ubuntu-latest

steps:
- name: Disallow production message
run: echo "This action is not allowed in production"

clear-db:
if: inputs.environment != 'Production'
if: ${{ inputs.environment != 'Production' }}
environment: ${{ inputs.environment }}
name: Clear user data from DB
runs-on: ubuntu-latest
Expand All @@ -36,6 +29,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Log Environment
run: |
echo "Environment: ${{ inputs.environment }}"

- name: Login with AZ
uses: ./.github/actions/azure-login
with:
Expand Down Expand Up @@ -65,7 +62,7 @@ jobs:
az_keyvault_name: ${{ env.az_keyvault_name }}
az_keyvault_database_connectionstring_name: ${{ env.az_keyvault_database_connectionstring_name }}

- name: Execute stored procedure
- name: Run clear DB SQL script
uses: azure/[email protected]
with:
connection-string: ${{ steps.get-connection-string.outputs.connection_string }}
Expand Down
Loading