All files / web/src/db/schema casbin-rules.ts

100% Statements 25/25
100% Branches 1/1
100% Functions 0/0
100% Lines 25/25

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 262x 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 { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
 
/**
 * Casbin rules table for dynamic resource-level authorization policies.
 *
 * Stores both policy rules (ptype='p') and role assignments (ptype='g').
 * Used by the custom Casbin adapter to load/save policies from the database.
 */
export const casbinRules = sqliteTable(
  'casbin_rules',
  {
    id: integer('id').primaryKey({ autoIncrement: true }),
    ptype: text('ptype').notNull(),
    v0: text('v0').notNull().default(''),
    v1: text('v1').notNull().default(''),
    v2: text('v2').notNull().default(''),
    v3: text('v3').notNull().default(''),
    v4: text('v4').notNull().default(''),
    v5: text('v5').notNull().default(''),
  },
  (table) => [index('idx_casbin_rules_ptype').on(table.ptype)]
)
 
export type CasbinRule = typeof casbinRules.$inferSelect
export type NewCasbinRule = typeof casbinRules.$inferInsert