first commit
This commit is contained in:
45
src/database/schema/profile.schema.ts
Normal file
45
src/database/schema/profile.schema.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { date, doublePrecision, pgEnum, pgTable, text, uuid, varchar } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user.schema';
|
||||
import { city, cityDistrict } from './city.schema';
|
||||
|
||||
export const genderEnum = pgEnum('gender', ['male', 'female']);
|
||||
|
||||
export const profile = pgTable('profile', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: uuid('user_id')
|
||||
.notNull()
|
||||
.unique()
|
||||
.references(() => user.id, { onDelete: 'cascade' }),
|
||||
name: varchar('name', { length: 100 }).notNull(),
|
||||
birthDate: date('birth_date').notNull(),
|
||||
gender: genderEnum('gender').notNull(),
|
||||
cityId: uuid('city_id').references(() => city.id, { onDelete: 'set null' }),
|
||||
districtId: uuid('district_id').references(() => cityDistrict.id, { onDelete: 'set null' }),
|
||||
description: text('description'),
|
||||
nation: varchar('nation', { length: 100 }),
|
||||
height: doublePrecision('height'),
|
||||
weight: doublePrecision('weight'),
|
||||
});
|
||||
|
||||
export const tag = pgTable('tag', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
value: varchar('value', { length: 100 }).notNull().unique(),
|
||||
});
|
||||
|
||||
export const profileTag = pgTable('profile_tag', {
|
||||
profileId: uuid('profile_id')
|
||||
.notNull()
|
||||
.references(() => profile.id, { onDelete: 'cascade' }),
|
||||
tagId: uuid('tag_id')
|
||||
.notNull()
|
||||
.references(() => tag.id, { onDelete: 'cascade' }),
|
||||
});
|
||||
|
||||
export const media = pgTable('media', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: uuid('user_id')
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: 'cascade' }),
|
||||
path: text('path').notNull(),
|
||||
type: varchar('type', { length: 10 }).notNull(),
|
||||
});
|
||||
Reference in New Issue
Block a user