Barazo AppView backend barazo.forum
at main 34 lines 1.0 kB view raw
1import { pgTable, text, integer, timestamp, index, primaryKey } from 'drizzle-orm/pg-core' 2 3export const interactionGraph = pgTable( 4 'interaction_graph', 5 { 6 sourceDid: text('source_did').notNull(), 7 targetDid: text('target_did').notNull(), 8 communityId: text('community_id').notNull(), 9 interactionType: text('interaction_type', { 10 enum: ['reply', 'reaction', 'topic_coparticipation'], 11 }).notNull(), 12 weight: integer('weight').notNull().default(1), 13 firstInteractionAt: timestamp('first_interaction_at', { 14 withTimezone: true, 15 }) 16 .notNull() 17 .defaultNow(), 18 lastInteractionAt: timestamp('last_interaction_at', { 19 withTimezone: true, 20 }) 21 .notNull() 22 .defaultNow(), 23 }, 24 (table) => [ 25 primaryKey({ 26 columns: [table.sourceDid, table.targetDid, table.communityId, table.interactionType], 27 }), 28 index('interaction_graph_source_target_community_idx').on( 29 table.sourceDid, 30 table.targetDid, 31 table.communityId 32 ), 33 ] 34)