mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
⭐ feat(www): Finish up on the onboarding (#210)
Merging this prematurely to make sure the team is on the same boat... like dang! We need to find a better way to do this. Plus it has become too big
This commit is contained in:
24
packages/scripts/src/db-reset.sh
Executable file
24
packages/scripts/src/db-reset.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
database=$(echo $SST_RESOURCE_Postgres | jq -r '.database')
|
||||
clusterArn=$(echo $SST_RESOURCE_Postgres | jq -r '.clusterArn')
|
||||
secretArn=$(echo $SST_RESOURCE_Postgres | jq -r '.secretArn')
|
||||
|
||||
sql=$(cat <<-'STMT'
|
||||
DO $$
|
||||
DECLARE
|
||||
row record;
|
||||
BEGIN
|
||||
FOR row IN SELECT * FROM pg_tables WHERE schemaname = 'public' OR schemaname = 'drizzle'
|
||||
LOOP
|
||||
EXECUTE 'DROP TABLE IF EXISTS public.' || quote_ident(row.tablename) || ' CASCADE';
|
||||
EXECUTE 'DROP TABLE IF EXISTS drizzle.' || quote_ident(row.tablename) || ' CASCADE';
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
STMT
|
||||
)
|
||||
|
||||
response=$(aws rds-data execute-statement --resource-arn $clusterArn --secret-arn $secretArn --database $database --sql "$sql" --format-records-as JSON)
|
||||
json=$(echo $response | jq -r '.formattedRecords')
|
||||
echo "$json" | jq .
|
||||
10
packages/scripts/src/psql.sh
Executable file
10
packages/scripts/src/psql.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
database=$(echo $SST_RESOURCE_Postgres | jq -r '.database')
|
||||
clusterArn=$(echo $SST_RESOURCE_Postgres | jq -r '.clusterArn')
|
||||
secretArn=$(echo $SST_RESOURCE_Postgres | jq -r '.secretArn')
|
||||
|
||||
sql="$@"
|
||||
response=$(aws rds-data execute-statement --resource-arn $clusterArn --secret-arn $secretArn --database $database --sql "$sql" --format-records-as JSON)
|
||||
json=$(echo $response | jq -r '.formattedRecords')
|
||||
echo "$json" | jq .
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { Resource } from "sst";
|
||||
import { spawnSync } from "bun";
|
||||
|
||||
spawnSync(
|
||||
[
|
||||
"psql",
|
||||
`postgresql://${Resource.Database.user}:${Resource.Database.password}@${Resource.Database.host}/${Resource.Database.name}?sslmode=require`,
|
||||
],
|
||||
{
|
||||
stdout: "inherit",
|
||||
stdin: "inherit",
|
||||
stderr: "inherit",
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user