refactor: remove catalog sync jobs and version history
This commit is contained in:
+5
-75
@@ -431,23 +431,9 @@ export const outboxEvents = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogVersions = catalogSchema.table(
|
||||
"version",
|
||||
{
|
||||
version: varchar("version", { length: 32 }).primaryKey(),
|
||||
active: boolean("active").default(false).notNull(),
|
||||
sourceTimestamp: bigint("source_timestamp", { mode: "number" }),
|
||||
syncedAt: timestamp("synced_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [uniqueIndex("catalog_active_unique").on(table.active).where(sql`${table.active} = true`)],
|
||||
);
|
||||
|
||||
export const catalogCharacters = catalogSchema.table(
|
||||
"character",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
.notNull()
|
||||
.references(() => catalogVersions.version, { onDelete: "cascade" }),
|
||||
key: varchar("key", { length: 64 }).notNull(),
|
||||
name: text("name").notNull(),
|
||||
element: varchar("element", { length: 48 }),
|
||||
@@ -460,45 +446,15 @@ export const catalogCharacters = catalogSchema.table(
|
||||
constellations: jsonb("constellations").$type<CatalogConstellation[]>().default([]).notNull(),
|
||||
talents: jsonb("talents").$type<CatalogTalent[]>().default([]).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({ columns: [table.version, table.key] }),
|
||||
index("catalog_character_name_idx").on(table.version, table.name),
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogCharacterCurrent = catalogSchema.table(
|
||||
"character_current",
|
||||
{
|
||||
key: varchar("key", { length: 64 }).notNull(),
|
||||
name: text("name").notNull(),
|
||||
element: varchar("element", { length: 48 }),
|
||||
rarity: integer("rarity"),
|
||||
weaponType: varchar("weapon_type", { length: 64 }),
|
||||
imageKey: text("image_key").notNull(),
|
||||
elementIconKey: text("element_icon_key"),
|
||||
splashImageKey: text("splash_image_key"),
|
||||
nameCardImageKey: text("name_card_image_key"),
|
||||
constellations: jsonb("constellations")
|
||||
.$type<CatalogConstellation[]>()
|
||||
.default([])
|
||||
.notNull(),
|
||||
talents: jsonb("talents")
|
||||
.$type<CatalogTalent[]>()
|
||||
.default([])
|
||||
.notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({ columns: [table.key] }),
|
||||
index("catalog_character_current_name_idx").on(table.name),
|
||||
index("catalog_character_name_idx").on(table.name),
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogWeapons = catalogSchema.table(
|
||||
"weapon",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
.notNull()
|
||||
.references(() => catalogVersions.version, { onDelete: "cascade" }),
|
||||
key: varchar("key", { length: 64 }).notNull(),
|
||||
name: text("name").notNull(),
|
||||
rarity: integer("rarity"),
|
||||
@@ -506,53 +462,30 @@ export const catalogWeapons = catalogSchema.table(
|
||||
imageKey: text("image_key").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({ columns: [table.version, table.key] }),
|
||||
index("catalog_weapon_name_idx").on(table.version, table.name),
|
||||
primaryKey({ columns: [table.key] }),
|
||||
index("catalog_weapon_name_idx").on(table.name),
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogArtifacts = catalogSchema.table(
|
||||
"artifact",
|
||||
{
|
||||
version: varchar("version", { length: 32 })
|
||||
.notNull()
|
||||
.references(() => catalogVersions.version, { onDelete: "cascade" }),
|
||||
key: varchar("key", { length: 64 }).notNull(),
|
||||
name: text("name").notNull(),
|
||||
rarity: integer("rarity"),
|
||||
imageKey: text("image_key").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({ columns: [table.version, table.key] }),
|
||||
index("catalog_artifact_name_idx").on(table.version, table.name),
|
||||
primaryKey({ columns: [table.key] }),
|
||||
index("catalog_artifact_name_idx").on(table.name),
|
||||
],
|
||||
);
|
||||
|
||||
export const catalogSyncJobs = catalogSchema.table(
|
||||
"sync_job",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
status: varchar("status", { length: 24 }).default("pending").notNull(),
|
||||
version: varchar("version", { length: 32 }),
|
||||
progress: integer("progress").default(0).notNull(),
|
||||
total: integer("total").default(0).notNull(),
|
||||
error: text("error"),
|
||||
triggeredById: text("triggered_by_id").references(() => users.id, { onDelete: "set null" }),
|
||||
startedAt: timestamp("started_at", { withTimezone: true }),
|
||||
completedAt: timestamp("completed_at", { withTimezone: true }),
|
||||
...timestamps,
|
||||
},
|
||||
(table) => [index("catalog_sync_status_idx").on(table.status, table.createdAt)],
|
||||
);
|
||||
|
||||
export const guides = guidesSchema.table(
|
||||
"guide",
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
characterKey: varchar("character_key", { length: 64 }).notNull(),
|
||||
catalogVersion: varchar("catalog_version", { length: 32 })
|
||||
.notNull()
|
||||
.references(() => catalogVersions.version, { onDelete: "restrict" }),
|
||||
slug: varchar("slug", { length: 120 }).notNull(),
|
||||
name: text("name").notNull(),
|
||||
overview: text("overview").notNull(),
|
||||
@@ -593,7 +526,6 @@ export const weaponRecommendations = guidesSchema.table(
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
guideId: uuid("guide_id").notNull().references(() => guides.id, { onDelete: "cascade" }),
|
||||
catalogVersion: varchar("catalog_version", { length: 32 }).notNull(),
|
||||
weaponKey: varchar("weapon_key", { length: 64 }).notNull(),
|
||||
refinement: integer("refinement").notNull(),
|
||||
overallPercent: numeric("overall_percent", { precision: 8, scale: 2 }),
|
||||
@@ -620,7 +552,6 @@ export const artifactRecommendations = guidesSchema.table(
|
||||
{
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
groupId: uuid("group_id").notNull().references(() => artifactGroups.id, { onDelete: "cascade" }),
|
||||
catalogVersion: varchar("catalog_version", { length: 32 }).notNull(),
|
||||
firstArtifactKey: varchar("first_artifact_key", { length: 64 }).notNull(),
|
||||
secondArtifactKey: varchar("second_artifact_key", { length: 64 }),
|
||||
percent: numeric("percent", { precision: 8, scale: 2 }).notNull(),
|
||||
@@ -672,7 +603,6 @@ export const teamMembers = guidesSchema.table(
|
||||
{
|
||||
teamId: uuid("team_id").notNull().references(() => teamCompositions.id, { onDelete: "cascade" }),
|
||||
position: integer("position").notNull(),
|
||||
catalogVersion: varchar("catalog_version", { length: 32 }).notNull(),
|
||||
characterKey: varchar("character_key", { length: 64 }).notNull(),
|
||||
weaponKey: varchar("weapon_key", { length: 64 }),
|
||||
artifactKey: varchar("artifact_key", { length: 64 }),
|
||||
|
||||
Reference in New Issue
Block a user