feat(region): Add admin region get + list endpoints (#6322)

**What**
Add `GET /admin/regions`
Add `GET /admin/regions/:id`

Blocked by #6320 

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Oli Juhl
2024-02-11 18:13:49 +01:00
committed by GitHub
parent b91a1ca5b8
commit 95d0e58d31
28 changed files with 566 additions and 87 deletions

View File

@@ -0,0 +1,32 @@
export function generatePostgresAlterColummnIfExistStatement(
tableName: string,
columns: string[],
alterExpression: string
) {
let script = `
DO $$
DECLARE
current_column text;
BEGIN`
columns.forEach((column) => {
script += `
current_column := '${column}';
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = '${tableName}'
AND column_name = current_column
) THEN
EXECUTE format('ALTER TABLE %I ALTER COLUMN %I ${alterExpression}', '${tableName}', current_column);
ELSE
RAISE NOTICE 'Column % does not exist or alteration condition not met.', current_column;
END IF;`
})
script += `
END$$;
`
return script
}

View File

@@ -1,3 +1,4 @@
export * from "./alter-columns-helper"
export * from "./array-difference"
export * from "./build-query"
export * from "./camel-to-snake-case"
@@ -45,3 +46,4 @@ export * from "./to-pascal-case"
export * from "./transaction"
export * from "./upper-case-first"
export * from "./wrap-handler"