Skip to content
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
32 changes: 32 additions & 0 deletions .cursor/rules/type-and-file-names.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: Type and file names use 3rd-person present verbs, not the infinitive, in Portuguese or English
globs: "{src,test}/**/*.{ts,js}"
alwaysApply: false
---

# Type and file names

Name new controllers, use cases, and their tests after the **action as a finite verb**: 3rd-person singular present (the form that agrees with “it does X”). Do not use the infinitive (“to X”) or the bare uninflected stem.

The same conjugation rule applies in Portuguese and in English. Keep the language of a module consistent; do not mix languages in one type or file name.

## How to name a type

1. Choose the action verb in the module’s language.
2. Inflect it to 3rd-person singular present.
3. Append the resource noun (plural for a collection, singular for one entity).
4. Append the role suffix (`Controller`, `UseCase`, and the same for other application/domain types).

| Role | Pattern |
| --- | --- |
| List a collection | `{Verb}{Resources}Controller` / `{Verb}{Resources}UseCase` |
| Get one by id | `{Verb}{Resource}UseCase` (and matching controller) |
| Tests | One file per action; kebab-case of the same verb + resource stem |

Type files are PascalCase and match the exported type. Test files use kebab-case of that stem (for example `lists-countries.test.ts`), not a different verb and not several actions in one file.

## When renaming

Delete the old file. Do not leave unused duplicates that use the infinitive or a different inflection.

Do not copy drifted names already in the tree. Match the inflection rule above for every new module.
4 changes: 0 additions & 4 deletions script/database-sync/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ RUN \
gnupg \
curl \
ca-certificates && \

curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql.gpg && \
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \

apt-get update && \
apt-get install -y \
postgresql-client-18 && \

apt-get remove -y \
curl \
ca-certificates \
gnupg && \

rm -rf /var/lib/apt/lists/*

ENV TZ=America/Sao_Paulo
Expand Down
22 changes: 18 additions & 4 deletions script/database-sync/database-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ set -euo pipefail

echo "Starting synchronization process..."

exclude_args=()
if [[ -n "${SYNC_EXCLUDE_TABLES:-}" ]]; then
IFS=$' \t\n,' read -r -a exclude_tables <<< "$SYNC_EXCLUDE_TABLES"
for table in "${exclude_tables[@]}"; do
[[ -z "$table" ]] && continue
exclude_args+=(--exclude-table="$table" --exclude-table="${table}_id_seq")
done
echo "Excluding tables: ${exclude_tables[*]}"
fi

# Plain SQL so we can CASCADE drops. Destination excluded tables keep their
# rows; CASCADE only removes leftover FKs that would block --clean.
PGPASSWORD="$SYNC_SOURCE_PASSWORD" pg_dump \
-h "$SYNC_SOURCE_HOST" \
-p "$SYNC_SOURCE_PORT" \
Expand All @@ -13,13 +25,15 @@ PGPASSWORD="$SYNC_SOURCE_PASSWORD" pg_dump \
--no-privileges \
--clean \
--if-exists \
--format=c | \
PGPASSWORD="$SYNC_DEST_PASSWORD" pg_restore \
"${exclude_args[@]}" | \
sed -E \
-e 's/^(DROP TABLE IF EXISTS .+);$/\1 CASCADE;/' \
-e 's/^(ALTER TABLE .+ DROP CONSTRAINT IF EXISTS .+);$/\1 CASCADE;/' | \
PGPASSWORD="$SYNC_DEST_PASSWORD" psql \
-h "$SYNC_DEST_HOST" \
-p "$SYNC_DEST_PORT" \
-U "$SYNC_DEST_USER" \
-d "$SYNC_DEST_DATABASE" \
--clean \
--if-exists
-v ON_ERROR_STOP=1

echo "Synchronization completed successfully: ${SYNC_SOURCE_DATABASE} -> ${SYNC_DEST_DATABASE}"
1 change: 1 addition & 0 deletions script/database-sync/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ services:
SYNC_DEST_USER: "postgres"
SYNC_DEST_PASSWORD: "masterkey"
SYNC_DEST_DATABASE: "herbario_dev"
# SYNC_EXCLUDE_TABLES: "public.usuarios"
CRON_SCHEDULE: "*/2 * * * *"
TZ: "America/Sao_Paulo"
Loading