From 68d67016aec8a47c709bff87e5c8f769ce69534b Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 2 Jul 2021 21:09:08 +0800 Subject: [PATCH] Add user table --- packages/schemas/src/db-entries/index.ts | 1 + packages/schemas/src/db-entries/user.ts | 22 ++++++++++++++++++++++ packages/schemas/src/gen/index.ts | 2 +- packages/schemas/tables/users.sql | 9 +++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 packages/schemas/src/db-entries/user.ts create mode 100644 packages/schemas/tables/users.sql diff --git a/packages/schemas/src/db-entries/index.ts b/packages/schemas/src/db-entries/index.ts index aa7d188fc..9b3d837b7 100644 --- a/packages/schemas/src/db-entries/index.ts +++ b/packages/schemas/src/db-entries/index.ts @@ -1,3 +1,4 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. export * from './oidc-model-instance'; +export * from './user'; diff --git a/packages/schemas/src/db-entries/user.ts b/packages/schemas/src/db-entries/user.ts new file mode 100644 index 000000000..0e6611bfc --- /dev/null +++ b/packages/schemas/src/db-entries/user.ts @@ -0,0 +1,22 @@ +// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. + +export type UserDBEntry = { + id: string; + userName?: string; + primaryEmail?: string; + primaryPhone?: string; + passwordEncrypted?: string; + passwordEncryptionMethod?: string; +}; + +export const Users = Object.freeze({ + table: 'users', + fields: { + id: 'id', + userName: 'user_name', + primaryEmail: 'primary_email', + primaryPhone: 'primary_phone', + passwordEncrypted: 'password_encrypted', + passwordEncryptionMethod: 'password_encryption_method', + }, +} as const); diff --git a/packages/schemas/src/gen/index.ts b/packages/schemas/src/gen/index.ts index 52948bec6..c04272703 100644 --- a/packages/schemas/src/gen/index.ts +++ b/packages/schemas/src/gen/index.ts @@ -45,7 +45,7 @@ const generate = async () => { .map((value) => normalizeWhitespaces(value)) .filter((value) => ['primary', 'foreign', 'unique', 'exclude', 'check'].every( - (constraint) => !value.startsWith(constraint) + (constraint) => !value.startsWith(constraint + ' ') ) ) .map((value) => { diff --git a/packages/schemas/tables/users.sql b/packages/schemas/tables/users.sql new file mode 100644 index 000000000..a2ed30544 --- /dev/null +++ b/packages/schemas/tables/users.sql @@ -0,0 +1,9 @@ +create table users ( + id varchar(24) not null, + user_name varchar(128) unique, + primary_email varchar(128) unique, + primary_phone varchar(128) unique, + password_encrypted varchar(128), + password_encryption_method varchar(32), + primary key (id) +);