my-kaiqiuwang/prisma/migrations/20260318045350_add_location_table/migration.sql
kyuuseiryuu fd8257e194 feat(api): add user location management endpoints and database model
- Added `UserLocation` model to `prisma/schema.prisma` to store user location data including coordinates (point geometry), name, avatar, and bindings to Logto and Kaiqiu users.
- Created new API endpoints under `/api/account/location` to handle location operations:
  - `POST`: Create a new location record for a user.
  - `GET`: Retrieve nearby locations based on latitude and longitude.
  - `PUT`: Update an existing location record, including coordinate updates via spatial index.
  - `DELETE`: Remove a specific location record.
- Integrated the custom spatial operations from `xprisma` DAO to support geospatial queries and updates.
- Updated dependencies to include `@mui/icons-material` (and its peer dependencies like `prop-types` and `react-transition-group` which are implicitly required by the new icon components).
- Implemented `verifyLogtoToken` logic to secure the new endpoints and associate locations with authenticated users.

No breaking changes in API contracts; new endpoints are additive.
2026-03-19 00:29:02 +09:00

12 lines
393 B
SQL

-- CreateTable
CREATE TABLE `UserLocation` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`logto_uid` VARCHAR(191) NOT NULL,
`name` VARCHAR(191) NOT NULL,
`coords` point NOT NULL,
INDEX `UserLocation_coords_idx`(`coords`),
UNIQUE INDEX `UserLocation_logto_uid_name_key`(`logto_uid`, `name`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;