add more detail to user

This commit is contained in:
2024-04-19 18:46:25 +07:00
parent 28f053e91b
commit 6b80ddd5e6
3 changed files with 37 additions and 20 deletions

View File

@@ -4,28 +4,42 @@ import {
integer,
primaryKey,
unique,
index,
} from "drizzle-orm/sqlite-core";
import { relations, sql } from "drizzle-orm";
//----------------User
export const user = sqliteTable("users", {
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
firstName: text("firstName").notNull(),
lastName: text("lastName").notNull(),
title: text("title").notNull(),
phone: text("phone").unique().notNull(),
email: text("email"),
job: text("job").notNull(),
education: text("education").notNull(),
vision: text("vision"),
reason: text("reason"),
group: integer("group_id")
.references(() => group.id)
.notNull(),
zone: integer("zone_id")
.notNull()
.references(() => zone.id),
});
export const user = sqliteTable(
"users",
{
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
firstName: text("firstName").notNull(),
lastName: text("lastName").notNull(),
title: text("title").notNull(),
cid: text("cid", { length: 13 }).notNull().unique(),
age: integer("age").notNull(),
phone: text("phone").unique().notNull(),
public_phone: text("public_phone"),
facebook: text("facebook"),
twitter: text("twitter"),
tiktok: text("tiktok"),
otherSocial: text("other_social"),
email: text("email"),
job: text("job").notNull(),
education: text("education").notNull(),
vision: text("vision"),
reason: text("reason"),
group: integer("group_id")
.references(() => group.id)
.notNull(),
zone: integer("zone_id")
.notNull()
.references(() => zone.id),
},
(t) => ({
phone_idx: index("phone_idx").on(t.phone),
})
);
export const userRelation = relations(user, ({ many, one }) => ({
opinions: many(userOpinion),