34 lines
1.5 KiB
Markdown
34 lines
1.5 KiB
Markdown
## ADDED Requirements
|
|
|
|
### Requirement: Shared Postgres database
|
|
The system SHALL use a single shared PostgreSQL database for all data. The canonical schema SHALL live in `db/schema.sql` until the Laravel admin takes over migration ownership.
|
|
|
|
#### Scenario: Schema applied to a fresh database
|
|
- **WHEN** `db/schema.sql` is applied to an empty database
|
|
- **THEN** the `users`, `tags`, and `scans` tables exist with the defined columns and constraints
|
|
|
|
### Requirement: Users table
|
|
The `users` table SHALL store id, unique email, password hash, name, phone, and created_at.
|
|
|
|
#### Scenario: Unique emails
|
|
- **WHEN** a second row is inserted with an email that already exists
|
|
- **THEN** the database rejects the insert
|
|
|
|
### Requirement: Tags table
|
|
The `tags` table SHALL store a unique public `tag_code`, owner reference, status (`unset`, `active`, `suspended`), item type, description, photo URL, phone, address, notes, and timestamps.
|
|
|
|
#### Scenario: Unique tag codes
|
|
- **WHEN** a second row is inserted with a tag_code that already exists
|
|
- **THEN** the database rejects the insert
|
|
|
|
#### Scenario: Status values
|
|
- **WHEN** a row is inserted with a status not in the allowed set
|
|
- **THEN** the database rejects the insert
|
|
|
|
### Requirement: Scans table
|
|
The `scans` table SHALL record tag scans with timestamp, optional latitude/longitude, whether location was shared, optional scanner phone, and whether an alert was sent.
|
|
|
|
#### Scenario: Recording a scan
|
|
- **WHEN** a scan of a tag is recorded
|
|
- **THEN** a row exists with tag reference, timestamp, and location flags
|