Add household and membership domain with role-based APIs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Introduced `Household` and `HouseholdMember` entities, services, and repositories, enabling role-based access (`OWNER` and `MEMBER`). Added REST APIs for household creation, member management, and listing. Configured Flyway migrations, updated tests, and included IntelliJ HTTP client script for API testing. Updated `README.md` with feature details, usage instructions, and architecture overview.
This commit is contained in:
26
src/main/resources/db/migration/V2__household.sql
Normal file
26
src/main/resources/db/migration/V2__household.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- src/main/resources/db/migration/V2__households.sql
|
||||
|
||||
-- Households & Members (H2/PG compatible)
|
||||
CREATE TABLE households (
|
||||
id UUID PRIMARY KEY,
|
||||
name VARCHAR(120) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE household_members (
|
||||
id UUID PRIMARY KEY,
|
||||
household_id UUID NOT NULL REFERENCES households(id) ON DELETE CASCADE,
|
||||
user_sub VARCHAR(64) NOT NULL,
|
||||
email VARCHAR(255),
|
||||
display_name VARCHAR(120),
|
||||
role VARCHAR(16) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (household_id, user_sub)
|
||||
);
|
||||
|
||||
-- Optional: enforce role values (H2 accepts the CHECK too)
|
||||
ALTER TABLE household_members
|
||||
ADD CONSTRAINT chk_household_role CHECK (role IN ('OWNER','MEMBER'));
|
||||
|
||||
CREATE INDEX idx_household_members_user_sub ON household_members(user_sub);
|
||||
CREATE INDEX idx_household_members_household ON household_members(household_id);
|
||||
Reference in New Issue
Block a user