Barazo AppView backend barazo.forum
at main 32 lines 1.3 kB view raw
1import { pgTable, pgPolicy, text, timestamp, index, serial } from 'drizzle-orm/pg-core' 2import { sql } from 'drizzle-orm' 3import { appRole } from './roles.js' 4 5export const topicNotices = pgTable( 6 'topic_notices', 7 { 8 id: serial('id').primaryKey(), 9 communityDid: text('community_did').notNull(), 10 topicUri: text('topic_uri').notNull(), 11 authorDid: text('author_did').notNull(), 12 noticeType: text('notice_type', { 13 enum: ['closed', 'moved', 'outdated', 'announcement', 'custom'], 14 }).notNull(), 15 headline: text('headline').notNull(), 16 body: text('body'), 17 createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), 18 dismissedAt: timestamp('dismissed_at', { withTimezone: true }), 19 }, 20 (table) => [ 21 index('topic_notices_community_did_idx').on(table.communityDid), 22 index('topic_notices_topic_uri_idx').on(table.topicUri), 23 index('topic_notices_created_at_idx').on(table.createdAt), 24 pgPolicy('tenant_isolation', { 25 as: 'permissive', 26 to: appRole, 27 for: 'all', 28 using: sql`community_did = current_setting('app.current_community_did', true)`, 29 withCheck: sql`community_did = current_setting('app.current_community_did', true)`, 30 }), 31 ] 32).enableRLS()