All files / web/src/db/schema feature-flags.ts

100% Statements 31/31
100% Branches 0/0
100% Functions 0/0
100% Lines 31/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 322x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
 
/**
 * Feature flags table
 *
 * Global on/off toggles with optional JSON config.
 * Designed for admin-controlled feature gating.
 */
export const featureFlags = sqliteTable('feature_flags', {
  /** Dot-namespaced identifier (e.g. 'billing.enabled') */
  key: text('key').primaryKey(),
 
  /** Whether the flag is active */
  enabled: integer('enabled', { mode: 'boolean' }).notNull().default(false),
 
  /** Optional JSON config attached to the flag */
  config: text('config'),
 
  /** Human-readable explanation shown in admin UI */
  description: text('description'),
 
  /** JSON array of roles allowed to see this flag, e.g. '["admin"]'. null = all roles. */
  allowedRoles: text('allowed_roles'),
 
  createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
 
  updatedAt: integer('updated_at', { mode: 'timestamp' }).notNull(),
})
 
export type FeatureFlag = typeof featureFlags.$inferSelect
export type NewFeatureFlag = typeof featureFlags.$inferInsert