util to create fake invites
This commit is contained in:
parent
6610b73731
commit
fe008a8906
1 changed files with 33 additions and 0 deletions
33
scripts/create_invite.sh
Normal file
33
scripts/create_invite.sh
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Load the .env file from the parent directory
|
||||||
|
source "$(dirname "$0")/../.env"
|
||||||
|
|
||||||
|
# Generate a random UUID for the record
|
||||||
|
UUID=$(uuidgen)
|
||||||
|
|
||||||
|
# Create a fake inviter_npub (using a random string here)
|
||||||
|
INVITER_NPUB="fake_inviter_${RANDOM}"
|
||||||
|
|
||||||
|
# Get the current timestamp for created_at
|
||||||
|
CREATED_AT=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
# Get the name of the PostgreSQL container from the docker-compose configuration
|
||||||
|
POSTGRES_CONTAINER_NAME=$(docker compose ps -q postgres | xargs docker inspect --format '{{.Name}}' | sed 's/\///')
|
||||||
|
|
||||||
|
|
||||||
|
docker exec -it "$POSTGRES_CONTAINER_NAME" psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -h localhost -p 5432 -c "\dt"
|
||||||
|
|
||||||
|
|
||||||
|
# Connect to the Postgres container and insert the fake record into the app_invite table
|
||||||
|
docker exec -i "$POSTGRES_CONTAINER_NAME" psql -v -U "$POSTGRES_USER" -d "$POSTGRES_DB" -h localhost -p 5432 -c "
|
||||||
|
INSERT INTO app_invite (uuid, inviter_npub, created_at)
|
||||||
|
VALUES ('$UUID', '$INVITER_NPUB', '$CREATED_AT')
|
||||||
|
RETURNING *;
|
||||||
|
"
|
||||||
|
|
||||||
|
# Print the generated values
|
||||||
|
echo "Inserted app_invite Record:"
|
||||||
|
echo "UUID: $UUID"
|
||||||
|
echo "Inviter Npub: $INVITER_NPUB"
|
||||||
|
echo "Created At: $CREATED_AT"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue