@@ -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 - FIXED to match database exactly
22+ // Snippet schema
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 ( "userid " ) , // FIXED: Match database column "userid"
31- createdAt : timestamp ( "createdat " ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "createdat"
32- updatedAt : timestamp ( "updatedat " ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "updatedat"
33- viewCount : integer ( "viewcount " ) . default ( 0 ) , // FIXED: Match database column "viewcount"
34- isFavorite : boolean ( "isfavorite " ) . default ( false ) , // FIXED: Match database column "isfavorite"
35- shareId : text ( "shareid " ) . unique ( ) , // FIXED: Match database column "shareid"
36- isPublic : boolean ( "ispublic " ) . default ( false ) , // FIXED: Match database column "ispublic"
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
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 - FIXED to match database exactly
51+ // Collections schema
5252export const collections = pgTable ( "collections" , {
5353 id : serial ( "id" ) . primaryKey ( ) ,
5454 name : text ( "name" ) . notNull ( ) ,
5555 description : text ( "description" ) ,
56- userId : text ( "userid " ) , // FIXED: Match database column "userid"
57- createdAt : timestamp ( "createdat " ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "createdat"
58- updatedAt : timestamp ( "updatedat " ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "updatedat"
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 ( ) ,
5959} ) ;
6060
6161export const insertCollectionSchema = createInsertSchema ( collections ) . omit ( {
@@ -83,14 +83,16 @@ export const insertCollectionItemSchema = createInsertSchema(collectionItems).om
8383export type InsertCollectionItem = z . infer < typeof insertCollectionItemSchema > ;
8484export type CollectionItem = typeof collectionItems . $inferSelect ;
8585
86- // Comments schema - FIXED to match actual database structure
86+ // Comments schema
8787export const comments = pgTable ( "comments" , {
8888 id : serial ( "id" ) . primaryKey ( ) ,
89- snippetId : integer ( "snippetid " ) . notNull ( ) , // FIXED: Match database column "snippetid"
89+ snippetId : integer ( "snippet_id " ) . notNull ( ) ,
9090 content : text ( "content" ) . notNull ( ) ,
91- userId : text ( "userid" ) , // FIXED: Match database column "userid"
92- createdAt : timestamp ( "createdat" ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "createdat"
93- updatedAt : timestamp ( "updatedat" ) . defaultNow ( ) . notNull ( ) , // FIXED: Match database column "updatedat"
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 ( ) ,
9496} ) ;
9597
9698export const insertCommentSchema = createInsertSchema ( comments ) . omit ( {
0 commit comments