a homebrewed DnD campaign based in the Honkai: Star Rail universe
hsr honkaistarrail dnd
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

db: update faction table to allow hierarchies

+15 -2
+15 -2
app/src/lib/server/db/schemas/dnd/faction.ts
··· 1 1 import { ne } from 'drizzle-orm' 2 - import { check, index, integer, pgEnum, pgTable, text, timestamp } from 'drizzle-orm/pg-core' 2 + import { 3 + check, 4 + foreignKey, 5 + index, 6 + integer, 7 + pgEnum, 8 + pgTable, 9 + text, 10 + timestamp, 11 + } from 'drizzle-orm/pg-core' 3 12 import { sourcebook } from './sourcebook' 4 13 5 14 export const faction = pgTable( 6 15 'faction', 7 16 { 8 17 id: integer('id').primaryKey().generatedAlwaysAsIdentity(), 18 + parentFactionId: integer('parent_faction_id'), 9 19 sourcebookId: integer('sourcebook_id') 10 20 .notNull() 11 21 .references(() => sourcebook.id), 12 22 name: text('name').notNull(), 13 23 description: text('description').notNull(), 14 24 }, 15 - (table) => [index().on(table.name)], 25 + (table) => [ 26 + index().on(table.name), 27 + foreignKey({ columns: [table.parentFactionId], foreignColumns: [table.id] }), 28 + ], 16 29 ) 17 30 18 31 export const factionRelationshipKind = pgEnum('faction_relationship_kind', [