preload import working
This commit is contained in:
@@ -1,9 +1,63 @@
|
||||
// src/db/schema.ts
|
||||
import { mysqlTable, serial, varchar, int } from 'drizzle-orm/mysql-core';
|
||||
import { mysqlTable, varchar, int, boolean, decimal, datetime, index } from 'drizzle-orm/mysql-core';
|
||||
|
||||
export const users = mysqlTable('users', {
|
||||
id: serial('id').notNull().primaryKey(),
|
||||
name: varchar('name', { length: 255 }).notNull(),
|
||||
age: int('age').notNull(),
|
||||
email: varchar('email', { length: 255 }).notNull(),
|
||||
export const cards = mysqlTable('cards', {
|
||||
productId: int().notNull().primaryKey(),
|
||||
productName: varchar({ length: 255 }).notNull(),
|
||||
productLineName: varchar({ length: 255 }).notNull().default(''),
|
||||
productLineUrlName: varchar({ length: 255 }).notNull().default(''),
|
||||
productStatusId: int().notNull().default(0),
|
||||
productTypeId: int().notNull().default(0),
|
||||
productUrlName: varchar({ length: 255 }).notNull().default(''),
|
||||
rarityName: varchar({ length: 100 }).notNull().default(''),
|
||||
score: decimal({ precision: 10, scale: 2 }).notNull().default('0'),
|
||||
sealed: boolean().notNull().default(false),
|
||||
sellerListable: boolean().notNull().default(false),
|
||||
setId: int().notNull().default(0),
|
||||
shippingCategoryId: int().notNull().default(0),
|
||||
duplicate: boolean().notNull().default(false),
|
||||
foilOnly: boolean().notNull().default(false),
|
||||
attack1: varchar({ length: 1024 }),
|
||||
attack2: varchar({ length: 1024 }),
|
||||
attack3: varchar({ length: 1024 }),
|
||||
attack4: varchar({ length: 1024 }),
|
||||
cardType: varchar({ length: 100 }),
|
||||
cardTypeB: varchar({ length: 100 }),
|
||||
energyType: varchar({ length: 100 }),
|
||||
flavorText: varchar({ length: 1000 }),
|
||||
hp: int().notNull().default(0),
|
||||
number: varchar({ length: 50 }).notNull().default(''),
|
||||
releaseDate: datetime(),
|
||||
resistance: varchar({ length: 100 }),
|
||||
retreatCost: varchar({ length: 100 }),
|
||||
stage: varchar({ length: 100 }),
|
||||
weakness: varchar({ length: 100 }),
|
||||
lowestPrice: decimal({ precision: 10, scale: 2 }).notNull().default('0'),
|
||||
lowestPriceWithShipping: decimal({ precision: 10, scale: 2 }).notNull().default('0'),
|
||||
marketPrice: decimal({ precision: 10, scale: 2 }).notNull().default('0'),
|
||||
maxFulfillableQuantity: int().notNull().default(0),
|
||||
medianPrice: decimal({ precision: 10, scale: 2 }).notNull().default('0'),
|
||||
totalListings: int().notNull().default(0),
|
||||
});
|
||||
|
||||
export const sets = mysqlTable('sets', {
|
||||
setId: int().notNull().primaryKey(),
|
||||
setCode: varchar({ length: 100 }).notNull(),
|
||||
setName: varchar({ length: 255 }).notNull(),
|
||||
setUrlName: varchar({ length: 255 }).notNull(),
|
||||
});
|
||||
|
||||
export const skus = mysqlTable('skus', {
|
||||
skuId: int().notNull().primaryKey(),
|
||||
productId: int().notNull(),
|
||||
condition: varchar({ length: 255 }).notNull(),
|
||||
language: varchar({ length: 100 }).notNull(),
|
||||
variant: varchar({ length: 100 }).notNull(),
|
||||
calculatedAt: datetime(),
|
||||
highestPrice: decimal({ precision: 10, scale: 2 }),
|
||||
lowestPrice: decimal({ precision: 10, scale: 2 }),
|
||||
marketPrice: decimal({ precision: 10, scale: 2 }),
|
||||
priceCount: int(),
|
||||
},(table) => ({
|
||||
productIdIdx: index('productIdIdx').on(table.productId),
|
||||
}));
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
// src/pages/users.astro
|
||||
import { db } from '../db/index';
|
||||
import { users } from '../db/schema';
|
||||
|
||||
const allUsers = await db.select().from(users);
|
||||
---
|
||||
|
||||
<h1>User List</h1>
|
||||
<ul>
|
||||
{allUsers.map((user) => (
|
||||
<li>{user.name} ({user.email})</li>
|
||||
))}
|
||||
</ul>
|
||||
Reference in New Issue
Block a user