feat(guides): organize schemas and export teams
This commit is contained in:
+41
-34
@@ -6,7 +6,7 @@ import {
|
||||
integer,
|
||||
jsonb,
|
||||
numeric,
|
||||
pgTable,
|
||||
pgSchema,
|
||||
primaryKey,
|
||||
text,
|
||||
timestamp,
|
||||
@@ -17,6 +17,13 @@ import {
|
||||
|
||||
import type { CatalogConstellation } from "@/lib/catalog/lunaris";
|
||||
|
||||
const authSchema = pgSchema("auth");
|
||||
const mediaSchema = pgSchema("media");
|
||||
const editorSchema = pgSchema("editor");
|
||||
const catalogSchema = pgSchema("catalog");
|
||||
const guidesSchema = pgSchema("guides");
|
||||
const operationsSchema = pgSchema("operations");
|
||||
|
||||
const timestamps = {
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.defaultNow()
|
||||
@@ -29,7 +36,7 @@ const timestamps = {
|
||||
|
||||
// Better Auth core tables. Credential registration is restricted to
|
||||
// ADMIN_EMAIL, which is rechecked at every protected application boundary.
|
||||
export const users = pgTable(
|
||||
export const users = authSchema.table(
|
||||
"user",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
@@ -42,7 +49,7 @@ export const users = pgTable(
|
||||
(table) => [uniqueIndex("user_email_unique").on(table.email)],
|
||||
);
|
||||
|
||||
export const sessions = pgTable(
|
||||
export const sessions = authSchema.table(
|
||||
"session",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
@@ -61,7 +68,7 @@ export const sessions = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const accounts = pgTable(
|
||||
export const accounts = authSchema.table(
|
||||
"account",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
@@ -90,7 +97,7 @@ export const accounts = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const verifications = pgTable(
|
||||
export const verifications = authSchema.table(
|
||||
"verification",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
@@ -102,7 +109,7 @@ export const verifications = pgTable(
|
||||
(table) => [index("verification_identifier_idx").on(table.identifier)],
|
||||
);
|
||||
|
||||
export const media = pgTable(
|
||||
export const media = mediaSchema.table(
|
||||
"media",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -134,7 +141,7 @@ export const media = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const characters = pgTable(
|
||||
export const characters = editorSchema.table(
|
||||
"character",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -158,7 +165,7 @@ export const characters = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const pages = pgTable(
|
||||
export const pages = editorSchema.table(
|
||||
"page",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -186,7 +193,7 @@ export const pages = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const blocks = pgTable(
|
||||
export const blocks = editorSchema.table(
|
||||
"block",
|
||||
{
|
||||
id: uuid("id").primaryKey(),
|
||||
@@ -206,7 +213,7 @@ export const blocks = pgTable(
|
||||
(table) => [index("block_page_order_idx").on(table.pageId, table.sortOrder)],
|
||||
);
|
||||
|
||||
export const dataSources = pgTable(
|
||||
export const dataSources = editorSchema.table(
|
||||
"data_source",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -219,7 +226,7 @@ export const dataSources = pgTable(
|
||||
(table) => [index("data_source_name_idx").on(table.name)],
|
||||
);
|
||||
|
||||
export const dataSourceVersions = pgTable(
|
||||
export const dataSourceVersions = editorSchema.table(
|
||||
"data_source_version",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -244,7 +251,7 @@ export const dataSourceVersions = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const pageDataSources = pgTable(
|
||||
export const pageDataSources = editorSchema.table(
|
||||
"page_data_source",
|
||||
{
|
||||
pageId: uuid("page_id")
|
||||
@@ -261,7 +268,7 @@ export const pageDataSources = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const templates = pgTable(
|
||||
export const templates = editorSchema.table(
|
||||
"template",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -276,7 +283,7 @@ export const templates = pgTable(
|
||||
(table) => [uniqueIndex("template_slug_unique").on(table.slug)],
|
||||
);
|
||||
|
||||
export const revisions = pgTable(
|
||||
export const revisions = editorSchema.table(
|
||||
"revision",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -310,7 +317,7 @@ export const revisions = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const publicSnapshots = pgTable(
|
||||
export const publicSnapshots = editorSchema.table(
|
||||
"public_snapshot",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -343,7 +350,7 @@ export const publicSnapshots = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const slugAliases = pgTable(
|
||||
export const slugAliases = editorSchema.table(
|
||||
"slug_alias",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -368,7 +375,7 @@ export const slugAliases = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const mediaReferences = pgTable(
|
||||
export const mediaReferences = mediaSchema.table(
|
||||
"media_reference",
|
||||
{
|
||||
mediaId: uuid("media_id")
|
||||
@@ -394,7 +401,7 @@ export const mediaReferences = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const outboxEvents = pgTable(
|
||||
export const outboxEvents = operationsSchema.table(
|
||||
"outbox_event",
|
||||
{
|
||||
id: bigint("id", { mode: "number" })
|
||||
@@ -424,7 +431,7 @@ export const outboxEvents = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogVersions = pgTable(
|
||||
export const catalogVersions = catalogSchema.table(
|
||||
"catalog_version",
|
||||
{
|
||||
version: varchar("version", { length: 32 }).primaryKey(),
|
||||
@@ -435,7 +442,7 @@ export const catalogVersions = pgTable(
|
||||
(table) => [uniqueIndex("catalog_active_unique").on(table.active).where(sql`${table.active} = true`)],
|
||||
);
|
||||
|
||||
export const catalogCharacters = pgTable(
|
||||
export const catalogCharacters = catalogSchema.table(
|
||||
"catalog_character",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
@@ -455,7 +462,7 @@ export const catalogCharacters = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogWeapons = pgTable(
|
||||
export const catalogWeapons = catalogSchema.table(
|
||||
"catalog_weapon",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
@@ -473,7 +480,7 @@ export const catalogWeapons = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogArtifacts = pgTable(
|
||||
export const catalogArtifacts = catalogSchema.table(
|
||||
"catalog_artifact",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
@@ -489,7 +496,7 @@ export const catalogArtifacts = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogSyncJobs = pgTable(
|
||||
export const catalogSyncJobs = catalogSchema.table(
|
||||
"catalog_sync_job",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -506,7 +513,7 @@ export const catalogSyncJobs = pgTable(
|
||||
(table) => [index("catalog_sync_status_idx").on(table.status, table.createdAt)],
|
||||
);
|
||||
|
||||
export const guides = pgTable(
|
||||
export const guides = guidesSchema.table(
|
||||
"guide",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -532,7 +539,7 @@ export const guides = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const guideSections = pgTable(
|
||||
export const guideSections = guidesSchema.table(
|
||||
"guide_section",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -549,7 +556,7 @@ export const guideSections = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const weaponRecommendations = pgTable(
|
||||
export const weaponRecommendations = guidesSchema.table(
|
||||
"weapon_recommendation",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -564,7 +571,7 @@ export const weaponRecommendations = pgTable(
|
||||
(table) => [index("weapon_recommendation_order_idx").on(table.guideId, table.sortOrder)],
|
||||
);
|
||||
|
||||
export const artifactGroups = pgTable(
|
||||
export const artifactGroups = guidesSchema.table(
|
||||
"artifact_group",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -575,7 +582,7 @@ export const artifactGroups = pgTable(
|
||||
(table) => [index("artifact_group_order_idx").on(table.guideId, table.sortOrder)],
|
||||
);
|
||||
|
||||
export const artifactRecommendations = pgTable(
|
||||
export const artifactRecommendations = guidesSchema.table(
|
||||
"artifact_recommendation",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -589,7 +596,7 @@ export const artifactRecommendations = pgTable(
|
||||
(table) => [index("artifact_recommendation_order_idx").on(table.groupId, table.sortOrder)],
|
||||
);
|
||||
|
||||
export const artifactProfiles = pgTable("artifact_profile", {
|
||||
export const artifactProfiles = guidesSchema.table("artifact_profile", {
|
||||
guideId: uuid("guide_id").primaryKey().references(() => guides.id, { onDelete: "cascade" }),
|
||||
sands: jsonb("sands").$type<string[]>().default([]).notNull(),
|
||||
goblet: jsonb("goblet").$type<string[]>().default([]).notNull(),
|
||||
@@ -601,7 +608,7 @@ export const artifactProfiles = pgTable("artifact_profile", {
|
||||
...timestamps,
|
||||
});
|
||||
|
||||
export const constellationRecommendations = pgTable(
|
||||
export const constellationRecommendations = guidesSchema.table(
|
||||
"constellation_recommendation",
|
||||
{
|
||||
guideId: uuid("guide_id").notNull().references(() => guides.id, { onDelete: "cascade" }),
|
||||
@@ -612,7 +619,7 @@ export const constellationRecommendations = pgTable(
|
||||
(table) => [primaryKey({ columns: [table.guideId, table.level] })],
|
||||
);
|
||||
|
||||
export const teamCompositions = pgTable(
|
||||
export const teamCompositions = guidesSchema.table(
|
||||
"team_composition",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -625,7 +632,7 @@ export const teamCompositions = pgTable(
|
||||
(table) => [index("team_composition_order_idx").on(table.guideId, table.sortOrder)],
|
||||
);
|
||||
|
||||
export const teamMembers = pgTable(
|
||||
export const teamMembers = guidesSchema.table(
|
||||
"team_member",
|
||||
{
|
||||
teamId: uuid("team_id").notNull().references(() => teamCompositions.id, { onDelete: "cascade" }),
|
||||
@@ -637,12 +644,12 @@ export const teamMembers = pgTable(
|
||||
(table) => [primaryKey({ columns: [table.teamId, table.position] })],
|
||||
);
|
||||
|
||||
export const extraSections = pgTable("extra_section", {
|
||||
export const extraSections = guidesSchema.table("extra_section", {
|
||||
sectionId: uuid("section_id").primaryKey().references(() => guideSections.id, { onDelete: "cascade" }),
|
||||
...timestamps,
|
||||
});
|
||||
|
||||
export const extraSectionRows = pgTable(
|
||||
export const extraSectionRows = guidesSchema.table(
|
||||
"extra_section_row",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
|
||||
Reference in New Issue
Block a user