[feat] implemented product variants
This commit is contained in:
@@ -4,8 +4,8 @@ import * as schema from "./schema.ts";
|
||||
export const relations = defineRelations(schema, (r) => ({
|
||||
skus: {
|
||||
card: r.one.cards({
|
||||
from: r.skus.productId,
|
||||
to: r.cards.productId,
|
||||
from: [r.skus.productId, r.skus.variant],
|
||||
to: [r.cards.productId, r.cards.variant],
|
||||
}),
|
||||
},
|
||||
cards: {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { mysqlTable, int, varchar, boolean, decimal, datetime, index } from "drizzle-orm/mysql-core"
|
||||
|
||||
export const cards = mysqlTable("cards", {
|
||||
export const tcgcards = mysqlTable("tcgcards", {
|
||||
productId: int().primaryKey(),
|
||||
originalProductName: varchar({ length: 255 }).default("").notNull(),
|
||||
productName: varchar({ length: 255 }).notNull(),
|
||||
productLineName: varchar({ length: 255 }).default("").notNull(),
|
||||
productLineUrlName: varchar({ length: 255 }).default("").notNull(),
|
||||
@@ -41,6 +40,39 @@ export const cards = mysqlTable("cards", {
|
||||
Artist: varchar({ length: 255 }),
|
||||
});
|
||||
|
||||
export const cards = mysqlTable("cards", {
|
||||
cardId: int().notNull().primaryKey().autoincrement(),
|
||||
productId: int().notNull(),
|
||||
variant: varchar({ length: 100 }).notNull(),
|
||||
productName: varchar({ length: 255 }),
|
||||
productLineName: varchar({ length: 255 }),
|
||||
productUrlName: varchar({ length: 255 }).default("").notNull(),
|
||||
rarityName: varchar({ length: 100 }),
|
||||
sealed: boolean().default(false).notNull(),
|
||||
setId: int(),
|
||||
cardType: varchar({ length: 100 }),
|
||||
energyType: varchar({ length: 100 }),
|
||||
number: varchar({ length: 50 }),
|
||||
Artist: varchar({ length: 255 }),
|
||||
},
|
||||
(table) => [
|
||||
index("card_productIdIdx").on(table.productId, table.variant),
|
||||
]);
|
||||
|
||||
export const tcg_overrides = mysqlTable("tcg_overrides", {
|
||||
productId: int().primaryKey(),
|
||||
productName: varchar({ length: 255 }),
|
||||
productLineName: varchar({ length: 255 }),
|
||||
productUrlName: varchar({ length: 255 }).default("").notNull(),
|
||||
rarityName: varchar({ length: 100 }),
|
||||
sealed: boolean().default(false).notNull(),
|
||||
setId: int(),
|
||||
cardType: varchar({ length: 100 }),
|
||||
energyType: varchar({ length: 100 }),
|
||||
number: varchar({ length: 50 }),
|
||||
Artist: varchar({ length: 255 }),
|
||||
});
|
||||
|
||||
export const sets = mysqlTable("sets", {
|
||||
setId: int().primaryKey(),
|
||||
setName: varchar({ length: 255 }).notNull(),
|
||||
@@ -50,6 +82,7 @@ export const sets = mysqlTable("sets", {
|
||||
|
||||
export const skus = mysqlTable("skus", {
|
||||
skuId: int().primaryKey(),
|
||||
cardId: int().default(0).notNull(),
|
||||
productId: int().notNull(),
|
||||
condition: varchar({ length: 255 }).notNull(),
|
||||
language: varchar({ length: 100 }).notNull(),
|
||||
@@ -61,7 +94,7 @@ export const skus = mysqlTable("skus", {
|
||||
priceCount: int(),
|
||||
},
|
||||
(table) => [
|
||||
index("productIdIdx").on(table.productId),
|
||||
index("productIdIdx").on(table.productId, table.variant),
|
||||
]);
|
||||
|
||||
export const processingSkus = mysqlTable("processingSkus", {
|
||||
|
||||
Reference in New Issue
Block a user