bilhej/backend
Joakim Mörling c03b5a1401 feat: add User entity, repository, service, and Flyway users table migration
- V1__create_users_table.sql replaces placeholder: creates users table with
  id UUID PK, email UNIQUE NOT NULL, password_hash NOT NULL, subscription
  VARCHAR(20) DEFAULT 'none' with CHECK constraint (none/basic/pro),
  created_at/updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP.
  Compatible with both H2 and PostgreSQL.

- SecurityConfig: minimal @Configuration providing BCryptPasswordEncoder
  bean. Required because Spring Boot 4 no longer auto-configures a
  PasswordEncoder.

- Subscription enum: NONE, BASIC, PRO with string values matching the DB
  CHECK constraint.

- User entity: @PrePersist generates UUID and timestamps in application
  code, @PreUpdate refreshes updated_at. Email setter normalizes to
  lowercase for case-insensitive uniqueness. Explicit getters/setters
  (no Lombok per guidelines).

- UserRepository: Spring Data JPA extending JpaRepository<User, UUID>.
  findByEmail(Optional) and existsByEmail for duplicate checks.

- UserService: @RequiredArgsConstructor with constructor-injected
  UserRepository and PasswordEncoder. createUser normalizes email,
  checks duplicates via existsByEmail, throws EmailAlreadyExistsException,
  hashes password with BCrypt, saves. findByEmail returns Optional<User>.

- EmailAlreadyExistsException: custom RuntimeException for duplicate
  registration attempts. ControllerAdvice handler deferred to auth ticket.

Verification: ./gradlew test passes (Flyway + H2 context loads).
docker compose up -d succeeds, Flyway applies V1 against PostgreSQL 16.
\d users confirms all columns, constraints, defaults, and indexes.
2026-05-01 02:06:24 +02:00
..
gradle/wrapper feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
src feat: add User entity, repository, service, and Flyway users table migration 2026-05-01 02:06:24 +02:00
.gitattributes feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
.gitignore feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
build.gradle feat: add Docker Compose setup with dev and prod configurations 2026-05-01 01:45:07 +02:00
gradlew feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
gradlew.bat feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
settings.gradle feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00