Barazo AppView backend barazo.forum
at main 24 lines 961 B view raw
1import { pgTable, text, timestamp, index, unique } from 'drizzle-orm/pg-core' 2 3export const votes = pgTable( 4 'votes', 5 { 6 uri: text('uri').primaryKey(), 7 rkey: text('rkey').notNull(), 8 authorDid: text('author_did').notNull(), 9 subjectUri: text('subject_uri').notNull(), 10 subjectCid: text('subject_cid').notNull(), 11 direction: text('direction').notNull(), 12 communityDid: text('community_did').notNull(), 13 cid: text('cid').notNull(), 14 createdAt: timestamp('created_at', { withTimezone: true }).notNull(), 15 indexedAt: timestamp('indexed_at', { withTimezone: true }).notNull().defaultNow(), 16 }, 17 (table) => [ 18 index('votes_author_did_idx').on(table.authorDid), 19 index('votes_subject_uri_idx').on(table.subjectUri), 20 index('votes_community_did_idx').on(table.communityDid), 21 // One vote per user per subject (regardless of direction) 22 unique('votes_author_subject_uniq').on(table.authorDid, table.subjectUri), 23 ] 24)