@@ -19,21 +19,21 @@ export const insertUserSchema = createInsertSchema(users).omit({
1919export type InsertUser = z . infer < typeof insertUserSchema > ;
2020export type User = typeof users . $inferSelect ;
2121
22- // Snippet schema
22+ // Snippet schema - Maps DB columns to TS properties
2323export const snippets = pgTable ( "snippets" , {
2424 id : serial ( "id" ) . primaryKey ( ) ,
2525 title : text ( "title" ) . notNull ( ) ,
2626 description : text ( "description" ) ,
2727 code : text ( "code" ) . notNull ( ) ,
2828 language : text ( "language" ) . notNull ( ) ,
2929 tags : text ( "tags" ) . array ( ) ,
30- userId : text ( "user_id " ) , // Changed from integer to text for Firebase UIDs
31- createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
32- updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
33- viewCount : integer ( "view_count " ) . default ( 0 ) ,
34- isFavorite : boolean ( "is_favorite " ) . default ( false ) ,
35- shareId : text ( "share_id " ) . unique ( ) , // Unique identifier for sharing
36- isPublic : boolean ( "is_public " ) . default ( false ) , // Controls if the snippet is publicly accessible
30+ userId : text ( "userid " ) , // TS property "userId" maps to DB column "userid"
31+ createdAt : timestamp ( "createdat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "createdAt" → DB "createdat"
32+ updatedAt : timestamp ( "updatedat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "updatedAt" → DB "updatedat"
33+ viewCount : integer ( "viewcount " ) . default ( 0 ) , // TS "viewCount" → DB "viewcount"
34+ isFavorite : boolean ( "isfavorite " ) . default ( false ) , // TS "isFavorite" → DB "isfavorite"
35+ shareId : text ( "shareid " ) . unique ( ) , // TS "shareId" → DB "shareid"
36+ isPublic : boolean ( "ispublic " ) . default ( false ) , // TS "isPublic" → DB "ispublic"
3737} ) ;
3838
3939export const insertSnippetSchema = createInsertSchema ( snippets ) . omit ( {
@@ -48,14 +48,14 @@ export const insertSnippetSchema = createInsertSchema(snippets).omit({
4848export type InsertSnippet = z . infer < typeof insertSnippetSchema > ;
4949export type Snippet = typeof snippets . $inferSelect ;
5050
51- // Collections schema
51+ // Collections schema - Maps DB columns to TS properties
5252export const collections = pgTable ( "collections" , {
5353 id : serial ( "id" ) . primaryKey ( ) ,
5454 name : text ( "name" ) . notNull ( ) ,
5555 description : text ( "description" ) ,
56- userId : text ( "user_id " ) , // Changed from integer to text for Firebase UIDs
57- createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
58- updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
56+ userId : text ( "userid " ) , // TS property "userId" maps to DB column "userid"
57+ createdAt : timestamp ( "createdat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "createdAt" → DB "createdat"
58+ updatedAt : timestamp ( "updatedat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "updatedAt" → DB "updatedat"
5959} ) ;
6060
6161export const insertCollectionSchema = createInsertSchema ( collections ) . omit ( {
@@ -67,7 +67,7 @@ export const insertCollectionSchema = createInsertSchema(collections).omit({
6767export type InsertCollection = z . infer < typeof insertCollectionSchema > ;
6868export type Collection = typeof collections . $inferSelect ;
6969
70- // Collection Items (for associating snippets with collections)
70+ // Collection Items
7171export const collectionItems = pgTable ( "collection_items" , {
7272 id : serial ( "id" ) . primaryKey ( ) ,
7373 collectionId : integer ( "collection_id" ) . notNull ( ) ,
@@ -83,16 +83,14 @@ export const insertCollectionItemSchema = createInsertSchema(collectionItems).om
8383export type InsertCollectionItem = z . infer < typeof insertCollectionItemSchema > ;
8484export type CollectionItem = typeof collectionItems . $inferSelect ;
8585
86- // Comments schema
86+ // Comments schema - Maps DB columns to TS properties
8787export const comments = pgTable ( "comments" , {
8888 id : serial ( "id" ) . primaryKey ( ) ,
89- snippetId : integer ( "snippet_id " ) . notNull ( ) ,
89+ snippetId : integer ( "snippetid " ) . notNull ( ) , // TS "snippetId" → DB "snippetid"
9090 content : text ( "content" ) . notNull ( ) ,
91- authorName : text ( "author_name" ) . notNull ( ) , // For guest comments without authentication
92- authorEmail : text ( "author_email" ) , // Optional email for notifications
93- userId : text ( "user_id" ) , // Changed from integer to text for Firebase UIDs
94- createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
95- updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
91+ userId : text ( "userid" ) , // TS "userId" → DB "userid"
92+ createdAt : timestamp ( "createdat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "createdAt" → DB "createdat"
93+ updatedAt : timestamp ( "updatedat" , { withTimezone : true } ) . defaultNow ( ) . notNull ( ) , // TS "updatedAt" → DB "updatedat"
9694} ) ;
9795
9896export const insertCommentSchema = createInsertSchema ( comments ) . omit ( {
0 commit comments