diff --git a/api/openapi.yaml b/api/openapi.yaml index b20f677..6439c86 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -196,7 +196,7 @@ paths: # error: # type: string - # /users: + /users: # get: # summary: Search user # parameters: @@ -218,28 +218,28 @@ paths: # items: # $ref: '#/components/schemas/User' - # post: - # summary: Add new user - # requestBody: - # required: true - # content: - # application/json: - # schema: - # $ref: '#/components/schemas/User' - # responses: - # '200': - # description: Add result - # content: - # application/json: - # schema: - # type: object - # properties: - # success: - # type: boolean - # error: - # type: string - # user_json: - # $ref: '#/components/schemas/User' + post: + summary: Add new user + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/User' + responses: + '200': + description: Add result + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + error: + type: string + user_json: + $ref: '#/components/schemas/User' # /users/{user_id}/titles: # get: @@ -580,7 +580,7 @@ components: required: - user_id - nickname - - creation_date + # - creation_date UserTitle: type: object additionalProperties: true diff --git a/sql/migrations/000001_init.up.sql b/sql/migrations/000001_init.up.sql index 0b7fa33..abecd32 100644 --- a/sql/migrations/000001_init.up.sql +++ b/sql/migrations/000001_init.up.sql @@ -27,8 +27,8 @@ CREATE TABLE users ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, avatar_id bigint REFERENCES images (id), passhash text NOT NULL, - mail text CHECK (mail ~ '[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+'), - nickname text NOT NULL CHECK (nickname ~ '^[a-zA-Z0-9_-]+$'), + mail text CHECK (mail ~ '^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+$'), + nickname text UNIQUE NOT NULL CHECK (nickname ~ '^[a-zA-Z0-9_-]{3,}$'), disp_name text, user_desc text, creation_date timestamptz NOT NULL, @@ -85,6 +85,12 @@ CREATE TABLE signals ( pending boolean NOT NULL ); +CREATE TABLE external_ids ( + user_id NOT NULL REFERENCES users (id), + service_id text NOT NULL, + external_ids text NOT NULL +); + -- Functions CREATE OR REPLACE FUNCTION update_title_rating() RETURNS TRIGGER AS $$