Add missing ZXDB ORM tables

Signed-off-by: codex@lucy.xalior.com
This commit is contained in:
2026-01-10 16:44:02 +00:00
parent f629cd0ca8
commit 686e057bb4

View File

@@ -1,4 +1,4 @@
import { mysqlTable, int, varchar, tinyint, char, smallint, decimal } from "drizzle-orm/mysql-core";
import { mysqlTable, int, varchar, tinyint, char, smallint, decimal, text, mediumtext, longtext } from "drizzle-orm/mysql-core";
// Minimal subset needed for browsing/searching
export const entries = mysqlTable("entries", {
@@ -342,3 +342,307 @@ export const magrefs = mysqlTable("magrefs", {
reviewId: int("review_id"),
awardId: tinyint("award_id"),
});
// ---- Extended ZXDB schema coverage (structure-only) ----
export const booktypeins = mysqlTable("booktypeins", {
entryId: int("entry_id").notNull(),
bookId: int("book_id").notNull(),
installment: smallint("installment").notNull().default(0),
volume: smallint("volume").notNull().default(0),
page: smallint("page").notNull().default(0),
isOriginal: tinyint("is_original").notNull().default(0),
});
export const countries = mysqlTable("countries", {
id: char("id", { length: 2 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const labeltypes = mysqlTable("labeltypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const licenses = mysqlTable("licenses", {
id: int("id").notNull().primaryKey(),
name: varchar("name", { length: 100 }).notNull(),
licensetypeId: char("licensetype_id", { length: 1 }).notNull(),
linkWikipedia: varchar("link_wikipedia", { length: 200 }),
linkSite: varchar("link_site", { length: 200 }),
comments: varchar("comments", { length: 500 }),
});
export const licensetypes = mysqlTable("licensetypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const licensors = mysqlTable("licensors", {
licenseId: int("license_id").notNull(),
labelId: int("label_id").notNull(),
});
export const magreffeats = mysqlTable("magreffeats", {
magrefId: int("magref_id").notNull(),
featureId: int("feature_id").notNull(),
});
export const magreflinks = mysqlTable("magreflinks", {
magrefId: int("magref_id").notNull(),
link: varchar("link", { length: 250 }).notNull(),
hostId: tinyint("host_id").notNull(),
});
export const magtypes = mysqlTable("magtypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const members = mysqlTable("members", {
tagId: int("tag_id").notNull(),
entryId: int("entry_id").notNull(),
categoryId: smallint("category_id").notNull().default(1),
memberSeq: smallint("member_seq"),
});
export const notes = mysqlTable("notes", {
id: int("id").notNull().primaryKey(),
entryId: int("entry_id"),
labelId: int("label_id"),
notetypeId: char("notetype_id", { length: 1 }).notNull(),
text: mediumtext("text").notNull(),
});
export const notetypes = mysqlTable("notetypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 100 }).notNull(),
});
export const nvgs = mysqlTable("nvgs", {
id: int("id").notNull().primaryKey(),
title: varchar("title", { length: 250 }).notNull(),
entryId: int("entry_id"),
fileLink: varchar("file_link", { length: 250 }),
fileDate: varchar("file_date", { length: 50 }),
fileSize: int("file_size"),
filetypeId: tinyint("filetype_id"),
isDemo: tinyint("is_demo").notNull().default(0),
machinetypeId: tinyint("machinetype_id"),
comments: varchar("comments", { length: 500 }),
url: varchar("url", { length: 100 }),
});
export const origintypes = mysqlTable("origintypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const permissions = mysqlTable("permissions", {
websiteId: tinyint("website_id").notNull(),
labelId: int("label_id").notNull(),
permissiontypeId: char("permissiontype_id", { length: 1 }).notNull(),
text: varchar("text", { length: 300 }),
});
export const permissiontypes = mysqlTable("permissiontypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const platforms = mysqlTable("platforms", {
id: tinyint("id").notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const ports = mysqlTable("ports", {
id: int("id").notNull().primaryKey(),
title: varchar("title", { length: 250 }),
entryId: int("entry_id").notNull(),
platformId: tinyint("platform_id").notNull(),
isOfficial: tinyint("is_official").notNull(),
linkSystem: varchar("link_system", { length: 200 }),
});
export const prefixes = mysqlTable("prefixes", {
text: varchar("text", { length: 10 }).notNull().primaryKey(),
});
export const prefixexempts = mysqlTable("prefixexempts", {
text: varchar("text", { length: 50 }).notNull().primaryKey(),
});
export const relatedlicenses = mysqlTable("relatedlicenses", {
entryId: int("entry_id").notNull(),
licenseId: int("license_id").notNull(),
isOfficial: tinyint("is_official").notNull(),
});
export const relations = mysqlTable("relations", {
entryId: int("entry_id").notNull(),
originalId: int("original_id").notNull(),
relationtypeId: char("relationtype_id", { length: 1 }).notNull(),
});
export const relationtypes = mysqlTable("relationtypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
reciprocal: varchar("reciprocal", { length: 50 }).notNull(),
comments: varchar("comments", { length: 250 }),
});
export const remakes = mysqlTable("remakes", {
id: int("id").notNull().primaryKey(),
entryId: int("entry_id").notNull(),
title: varchar("title", { length: 250 }).notNull(),
fileLink: varchar("file_link", { length: 250 }).notNull(),
fileDate: varchar("file_date", { length: 50 }),
fileSize: int("file_size"),
authors: varchar("authors", { length: 250 }),
platforms: varchar("platforms", { length: 200 }),
remakeYears: varchar("remake_years", { length: 100 }),
remakeStatus: varchar("remake_status", { length: 1000 }),
});
export const scores = mysqlTable("scores", {
websiteId: tinyint("website_id").notNull(),
entryId: int("entry_id").notNull(),
score: decimal("score", { precision: 5, scale: 2 }).notNull(),
votes: int("votes").notNull(),
});
export const scraps = mysqlTable("scraps", {
id: int("id").notNull().primaryKey(),
entryId: int("entry_id"),
releaseSeq: smallint("release_seq"),
fileLink: varchar("file_link", { length: 250 }),
fileDate: varchar("file_date", { length: 50 }),
fileSize: int("file_size"),
filetypeId: tinyint("filetype_id").notNull(),
languageId: char("language_id", { length: 2 }),
isDemo: tinyint("is_demo").notNull(),
schemetypeId: char("schemetype_id", { length: 2 }),
machinetypeId: tinyint("machinetype_id"),
fileCode: varchar("file_code", { length: 50 }),
fileBarcode: varchar("file_barcode", { length: 50 }),
fileDl: varchar("file_dl", { length: 150 }),
casetypeId: char("casetype_id", { length: 1 }),
sourcetypeId: char("sourcetype_id", { length: 1 }),
releaseYear: smallint("release_year"),
comments: varchar("comments", { length: 250 }),
rationale: varchar("rationale", { length: 100 }).notNull(),
});
export const searchByAliases = mysqlTable("search_by_aliases", {
entryId: int("entry_id").notNull(),
title: varchar("title", { length: 250 }).notNull(),
libraryTitle: varchar("library_title", { length: 300 }).notNull(),
});
export const searchByIssues = mysqlTable("search_by_issues", {
issueId: int("issue_id").notNull().primaryKey(),
name: varchar("name", { length: 300 }).notNull(),
});
export const searchByMagazines = mysqlTable("search_by_magazines", {
magazineId: smallint("magazine_id").notNull(),
labelId: int("label_id").notNull(),
});
export const searchByMagrefs = mysqlTable("search_by_magrefs", {
entryId: int("entry_id").notNull(),
magrefId: int("magref_id").notNull(),
});
export const searchByOrigins = mysqlTable("search_by_origins", {
entryId: int("entry_id").notNull().primaryKey(),
libraryTitle: varchar("library_title", { length: 300 }).notNull(),
origintypeId: char("origintype_id", { length: 1 }).notNull(),
containerId: int("container_id"),
issueId: int("issue_id"),
dateYear: smallint("date_year"),
dateMonth: smallint("date_month"),
dateDay: smallint("date_day"),
publication: varchar("publication", { length: 300 }),
});
export const spexAuthors = mysqlTable("spex_authors", {
id: int("id").notNull().primaryKey(),
entryId: int("entry_id").notNull(),
name: varchar("name", { length: 150 }).notNull(),
labelId: int("label_id"),
});
export const spexEntries = mysqlTable("spex_entries", {
id: int("id").notNull().primaryKey(),
title: varchar("title", { length: 150 }).notNull(),
entryId: int("entry_id").notNull(),
releaseSeq: smallint("release_seq"),
pub1LabelId: int("pub1_label_id"),
pub2LabelId: int("pub2_label_id"),
pub3LabelId: int("pub3_label_id"),
genretypeId: tinyint("genretype_id"),
orgprice: decimal("orgprice", { precision: 5, scale: 2 }).notNull(),
repub2price: decimal("repub2price", { precision: 5, scale: 2 }).notNull(),
repub3price: decimal("repub3price", { precision: 5, scale: 2 }).notNull(),
diskprice: decimal("diskprice", { precision: 5, scale: 2 }).notNull(),
fgtkey: varchar("fgtkey", { length: 150 }).notNull(),
});
export const tags = mysqlTable("tags", {
id: int("id").notNull().primaryKey(),
name: varchar("name", { length: 100 }).notNull(),
link: varchar("link", { length: 200 }),
comments: varchar("comments", { length: 1500 }),
tagtypeId: char("tagtype_id", { length: 1 }).notNull(),
toolId: int("tool_id"),
});
export const tagtypes = mysqlTable("tagtypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const topics = mysqlTable("topics", {
id: int("id").notNull().primaryKey(),
topictypeId: char("topictype_id", { length: 1 }).notNull(),
labelId: int("label_id"),
magazineId: smallint("magazine_id"),
name: varchar("name", { length: 150 }).notNull(),
comments: varchar("comments", { length: 150 }),
});
export const topictypes = mysqlTable("topictypes", {
id: char("id", { length: 1 }).notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
});
export const zxsrAwards = mysqlTable("zxsr_awards", {
id: tinyint("id").notNull().primaryKey(),
name: varchar("text", { length: 50 }).notNull(),
magazineId: smallint("magazine_id").notNull(),
});
export const zxsrCaptions = mysqlTable("zxsr_captions", {
magrefId: int("magref_id").notNull(),
captionSeq: smallint("caption_seq").notNull(),
text: text("text").notNull(),
isBanner: tinyint("is_banner").notNull(),
});
export const zxsrReviews = mysqlTable("zxsr_reviews", {
id: int("id").notNull().primaryKey(),
introText: longtext("intro_text"),
reviewText: longtext("review_text"),
reviewRating: varchar("review_rating", { length: 2000 }),
});
export const zxsrScores = mysqlTable("zxsr_scores", {
id: int("id").notNull().primaryKey(),
magrefId: int("magref_id").notNull(),
scoreSeq: tinyint("score_seq"),
category: varchar("category", { length: 100 }).notNull(),
isOverall: tinyint("is_overall").notNull().default(0),
score: varchar("score", { length: 100 }),
comments: text("comments"),
});