feat: introduce full name column to user model

This commit is contained in:
Ali BARIN
2023-03-01 21:40:39 +00:00
parent 282863c526
commit 74a299dbe6
5 changed files with 22 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ export async function createUser(
const userParams = {
email,
password,
fullName: 'Initial admin',
role: 'admin',
};

View File

@@ -0,0 +1,15 @@
import { Knex } from 'knex';
export async function up(knex: Knex): Promise<void> {
return knex.schema.table('users', async (table) => {
table.string('full_name');
await knex('users').update({ full_name: 'Initial admin' });
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.table('users', (table) => {
table.dropColumn('full_name');
});
}

View File

@@ -427,7 +427,9 @@ input StepInput {
type User {
id: String
fullName: String
email: String
role: String
createdAt: String
updatedAt: String
}

View File

@@ -9,6 +9,7 @@ import crypto from 'crypto';
class User extends Base {
id!: string;
fullName!: string;
email!: string;
password!: string;
role: string;
@@ -23,10 +24,11 @@ class User extends Base {
static jsonSchema = {
type: 'object',
required: ['email', 'password'],
required: ['fullName', 'email', 'password'],
properties: {
id: { type: 'string', format: 'uuid' },
fullName: { type: 'string', minLength: 1 },
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
password: { type: 'string', minLength: 1, maxLength: 255 },
role: { type: 'string', enum: ['admin', 'user'] },

View File

@@ -4,6 +4,7 @@ export const GET_CURRENT_USER = gql`
query GetCurrentUser {
getCurrentUser {
id
fullName
email
createdAt
updatedAt