export const users = pgTable('users', {
id: uuid().notNull().primaryKey().defaultRandom(),
email: text().notNull().unique(),
password: text().notNull(),
code: text().notNull(),
isVerified: boolean().notNull().default(false),
type: pgEnum('user_type', ['customer', 'artist'])(),
firstName: text(),
lastName: text(),
city: text(),
nickname: text(),
isSetupComplete: boolean().generatedAlwaysAs(
(): SQL => sql`CASE
WHEN ${users.isVerified} = true
AND ${users.firstName} IS NOT NULL
AND ${users.lastName} IS NOT NULL
AND ${users.city} IS NOT NULL
AND ${users.type} IS NOT NULL
AND (
${users.type} = 'customer'
OR (${users.type} = 'artist' AND ${users.nickname} IS NOT NULL)
)
THEN true
ELSE false
END`,
),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp().notNull().defaultNow(),
});
export const users = pgTable('users', {
id: uuid().notNull().primaryKey().defaultRandom(),
email: text().notNull().unique(),
password: text().notNull(),
code: text().notNull(),
isVerified: boolean().notNull().default(false),
type: pgEnum('user_type', ['customer', 'artist'])(),
firstName: text(),
lastName: text(),
city: text(),
nickname: text(),
isSetupComplete: boolean().generatedAlwaysAs(
(): SQL => sql`CASE
WHEN ${users.isVerified} = true
AND ${users.firstName} IS NOT NULL
AND ${users.lastName} IS NOT NULL
AND ${users.city} IS NOT NULL
AND ${users.type} IS NOT NULL
AND (
${users.type} = 'customer'
OR (${users.type} = 'artist' AND ${users.nickname} IS NOT NULL)
)
THEN true
ELSE false
END`,
),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp().notNull().defaultNow(),
});