-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix blogs validation part 2, remove last_update_date (#242)
* Fix blog validations on client * Remove last_update_date * Make b:push run first --------- Co-authored-by: Ricky Zhang <[email protected]> Co-authored-by: UF SASE Webmaster <[email protected]>
- Loading branch information
1 parent
5c67f52
commit 6d6a0e5
Showing
6 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { relations } from "drizzle-orm/relations"; | ||
import { blog, blogTag, blogTagRelationship, mentorMenteeRelationship, personalInfo, professionalInfo, saseInfo, session, user } from "./schema"; | ||
|
||
export const blogTagRelationshipRelations = relations(blogTagRelationship, ({ one }) => ({ | ||
blogTag: one(blogTag, { | ||
fields: [blogTagRelationship.tagId], | ||
references: [blogTag.id], | ||
}), | ||
blog: one(blog, { | ||
fields: [blogTagRelationship.blogId], | ||
references: [blog.id], | ||
}), | ||
})); | ||
|
||
export const blogTagRelations = relations(blogTag, ({ many }) => ({ | ||
blogTagRelationships: many(blogTagRelationship), | ||
})); | ||
|
||
export const blogRelations = relations(blog, ({ many, one }) => ({ | ||
blogTagRelationships: many(blogTagRelationship), | ||
user: one(user, { | ||
fields: [blog.author_id], | ||
references: [user.id], | ||
}), | ||
})); | ||
|
||
export const userRelations = relations(user, ({ many }) => ({ | ||
blogs: many(blog), | ||
mentorMenteeRelationships_menteeId: many(mentorMenteeRelationship, { | ||
relationName: "mentorMenteeRelationship_menteeId_user_id", | ||
}), | ||
mentorMenteeRelationships_mentorId: many(mentorMenteeRelationship, { | ||
relationName: "mentorMenteeRelationship_mentorId_user_id", | ||
}), | ||
sessions: many(session), | ||
personalInfos: many(personalInfo), | ||
professionalInfos: many(professionalInfo), | ||
saseInfos: many(saseInfo), | ||
})); | ||
|
||
export const mentorMenteeRelationshipRelations = relations(mentorMenteeRelationship, ({ one }) => ({ | ||
user_menteeId: one(user, { | ||
fields: [mentorMenteeRelationship.menteeId], | ||
references: [user.id], | ||
relationName: "mentorMenteeRelationship_menteeId_user_id", | ||
}), | ||
user_mentorId: one(user, { | ||
fields: [mentorMenteeRelationship.mentorId], | ||
references: [user.id], | ||
relationName: "mentorMenteeRelationship_mentorId_user_id", | ||
}), | ||
})); | ||
|
||
export const sessionRelations = relations(session, ({ one }) => ({ | ||
user: one(user, { | ||
fields: [session.userId], | ||
references: [user.id], | ||
}), | ||
})); | ||
|
||
export const personalInfoRelations = relations(personalInfo, ({ one }) => ({ | ||
user: one(user, { | ||
fields: [personalInfo.userId], | ||
references: [user.id], | ||
}), | ||
})); | ||
|
||
export const professionalInfoRelations = relations(professionalInfo, ({ one }) => ({ | ||
user: one(user, { | ||
fields: [professionalInfo.userId], | ||
references: [user.id], | ||
}), | ||
})); | ||
|
||
export const saseInfoRelations = relations(saseInfo, ({ one }) => ({ | ||
user: one(user, { | ||
fields: [saseInfo.userId], | ||
references: [user.id], | ||
}), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
// import { sql } from "drizzle-orm"; | ||
import { blob, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core"; | ||
|
||
export const blogTagRelationship = sqliteTable("blog_tag_relationship", { | ||
id: text().primaryKey().notNull(), | ||
blogId: text("blog_id").references(() => blog.id), | ||
tagId: text("tag_id").references(() => blogTag.id), | ||
}); | ||
|
||
export const blogTag = sqliteTable( | ||
"blog_tag", | ||
{ | ||
id: text().primaryKey().notNull(), | ||
name: text().notNull(), | ||
}, | ||
(table) => { | ||
return { | ||
nameUnique: uniqueIndex("blog_tag_name_unique").on(table.name), | ||
}; | ||
}, | ||
); | ||
|
||
export const blog = sqliteTable( | ||
"blog", | ||
{ | ||
id: text().primaryKey().notNull(), | ||
title: text().notNull(), | ||
content: text().notNull(), | ||
author_id: text("author_id").references(() => user.id), | ||
published_date: integer("published_date").notNull(), | ||
last_update_date: text("last_update_date"), | ||
time_updated: integer("time_updated").notNull(), | ||
}, | ||
(table) => { | ||
return { | ||
titleUnique: uniqueIndex("blog_title_unique").on(table.title), | ||
}; | ||
}, | ||
); | ||
|
||
export const event = sqliteTable( | ||
"event", | ||
{ | ||
id: text().primaryKey().notNull(), | ||
name: text().notNull(), | ||
description: text(), | ||
location: text().notNull(), | ||
startTime: integer("start_time").notNull(), | ||
endTime: integer("end_time").notNull(), | ||
involvedGroups: text("involved_groups"), | ||
timeAdded: integer("time_added").notNull(), | ||
time_updated: integer("time_updated").notNull(), | ||
slidesUrl: text("slides_url"), | ||
}, | ||
(table) => { | ||
return { | ||
nameUnique: uniqueIndex("event_name_unique").on(table.name), | ||
}; | ||
}, | ||
); | ||
|
||
export const mentorMenteeRelationship = sqliteTable("mentor_mentee_relationship", { | ||
id: text().primaryKey().notNull(), | ||
mentorId: text("mentor_id").references(() => user.id), | ||
menteeId: text("mentee_id").references(() => user.id), | ||
}); | ||
|
||
export const session = sqliteTable("session", { | ||
id: text().primaryKey().notNull(), | ||
userId: text("user_id") | ||
.notNull() | ||
.references(() => user.id), | ||
expiresAt: integer("expires_at").notNull(), | ||
}); | ||
|
||
export const user = sqliteTable( | ||
"user", | ||
{ | ||
id: text().primaryKey().notNull(), | ||
username: text().notNull(), | ||
points: integer(), | ||
roles: text(), | ||
timeAdded: integer("time_added").notNull(), | ||
time_updated: integer("time_updated").notNull(), | ||
password: text().notNull(), | ||
}, | ||
(table) => { | ||
return { | ||
usernameUnique: uniqueIndex("user_username_unique").on(table.username), | ||
}; | ||
}, | ||
); | ||
|
||
export const emailSubscriber = sqliteTable( | ||
"email_subscriber", | ||
{ | ||
id: text().primaryKey().notNull(), | ||
email: text().notNull(), | ||
name: text(), | ||
subscribedAt: integer("subscribed_at").notNull(), | ||
}, | ||
(table) => { | ||
return { | ||
emailUnique: uniqueIndex("email_subscriber_email_unique").on(table.email), | ||
}; | ||
}, | ||
); | ||
|
||
export const personalInfo = sqliteTable( | ||
"personal_info", | ||
{ | ||
userId: text("user_id") | ||
.primaryKey() | ||
.notNull() | ||
.references(() => user.id), | ||
firstName: text("first_name").notNull(), | ||
lastName: text("last_name").notNull(), | ||
email: text().notNull(), | ||
phone: blob(), | ||
areaCode: integer("area_code"), | ||
}, | ||
(table) => { | ||
return { | ||
phoneUnique: uniqueIndex("personal_info_phone_unique").on(table.phone), | ||
emailUnique: uniqueIndex("personal_info_email_unique").on(table.email), | ||
}; | ||
}, | ||
); | ||
|
||
export const professionalInfo = sqliteTable("professional_info", { | ||
userId: text("user_id") | ||
.primaryKey() | ||
.notNull() | ||
.references(() => user.id), | ||
resumePath: text("resume_path"), | ||
linkedin: text(), | ||
portfolio: text(), | ||
majors: text(), | ||
minors: text(), | ||
graduationSemester: text("graduation_semester"), | ||
}); | ||
|
||
export const saseInfo = sqliteTable("sase_info", { | ||
userId: text("user_id") | ||
.primaryKey() | ||
.notNull() | ||
.references(() => user.id), | ||
eventsAttended: text("events_attended"), | ||
groups: text(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters