# DB Task Generator
This directory is home to the generator scripts that assist in generating correctly named db files for a variety of repetitive DB tasks.

**Note:** all generator tasks can be run with or without arguments. If no args are passed you will be prompted for the required info. See each task's script file in `./scripts/generators` for detailed usage.

## Recommended Setup
The generators need your Identity ID and username. Rather than passing them in as args every time, set them as env vars in your shell by creating a `.env` file:
```shell
cp ./scripts/.env.shadow ./scripts/.env
```
Then open `./scripts/.env` and fill out the values.

## Create Abacus Profiles
New users that need to be granted access to Abacus.

```shell
./scripts/generate.sh create-abacus-profiles
```
The above command will generate a new `cypher` file that will create the access node in neo4j for the given user(s) once the `db-depoy-pipeline` is run for it. Command output will instruct you in an additional manual task (email unmasking).

More info: https://www.notion.so/Creating-ABACUS-Profiles-bb09f766bf9e4770b6e40454ab0b4122

## Delete Abacus Profile
Removes user(s) Abacus access.

```shell
./scripts/generate.sh delete-abacus-profiles
```

## Hard Delete Accounts
Permanently removes account(s)

```shell
./scripts/generate.sh hard-delete-accounts
```

## Hard Delete Contracts
Permanently removes contract(s)

```shell
./scripts/generate.sh hard-delete-contracts
```

## Schema Updates
New columns or tables - should be done via the Liquibase SQL file generated by this command.

```shell
./scripts/generate.sh create-ddl-file
```

## Data Migration
Insert/Update/Delete rows in the database - should be done via the Liquibase SQL file generated by this command.

```shell
./scripts/generate.sh create-dml-file
```

**Note:** Open the generated file and implement the SQL needed for your database change. Must include the rollback commands at the bottom of the file.

**More info:** https://www.notion.so/Database-Deploy-Process-3742829fd69d49469cba7e22ca80bcad

## Resync Contract VAT Details
Generates a Kafka changelog XML file for resyncing contract VAT details. This sends UPDATE events to the `event.abacus.contract` Kafka topic for specified contract IDs.

```shell
./scripts/generate.sh resync-contract-vat-details
```

The generator will prompt you for:
- **ticket_num**: The JIRA ticket number (e.g., ACC-9999)
- **dev_username**: Your developer username
- **contract_ids**: Comma-separated list of contract IDs (e.g., 123456,234567,345678)

Example with arguments:
```shell
./scripts/generate.sh resync-contract-vat-details "123456,234567,345678" ACC-9999 mrojas
```
