mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
deleted separate schema files
This commit is contained in:
@@ -2,27 +2,27 @@
|
|||||||
import { eq, not , asc} from "drizzle-orm";
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { Account } from "../db/schema/Account";
|
import { accounts } from "@schemas/schema";
|
||||||
|
|
||||||
export const getData = async () => {
|
export const getData = async () => {
|
||||||
const data = await db.select().from(Account).orderBy(asc(Account.last_name));
|
const data = await db.select().from(accounts).orderBy(asc(accounts.last_name));
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||||
await db.insert(Account).values({
|
/* await db.insert(accounts).values({
|
||||||
first_name : first_name, last_name: last_name, username: username, password_hash : password_hash
|
first_name : first_name, last_name: last_name, username: username, password_hash : password_hash
|
||||||
});
|
}); */
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteAccount = async (id: number) => {
|
export const deleteAccount = async (id: number) => {
|
||||||
await db.delete(Account).where(eq(Account.id, id));
|
await db.delete(accounts).where(eq(accounts.userId, id));
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
};
|
};
|
||||||
|
|
||||||
export const editAccount = async (id: number, first_name: string, last_name: string, username: string, email : string, password_hash: string) => {
|
export const editAccount = async (id: number, first_name: string, last_name: string, username: string, email : string, password_hash: string) => {
|
||||||
await db
|
await db
|
||||||
.update(Account)
|
.update(accounts)
|
||||||
.set({
|
.set({
|
||||||
first_name : first_name,
|
first_name : first_name,
|
||||||
last_name: last_name,
|
last_name: last_name,
|
||||||
@@ -30,6 +30,6 @@ export const editAccount = async (id: number, first_name: string, last_name: str
|
|||||||
email: email,
|
email: email,
|
||||||
password_hash: password_hash
|
password_hash: password_hash
|
||||||
})
|
})
|
||||||
.where(eq(Account.id, id));
|
.where(eq(accounts.userId, id));
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
};
|
};
|
||||||
@@ -2,30 +2,30 @@
|
|||||||
import { eq, not , asc} from "drizzle-orm";
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { brand } from "@db/schema/Brand";
|
import { brands } from "@schemas/schema";
|
||||||
export const getData = async () => {
|
export const getData = async () => {
|
||||||
const data = await db.select().from(brand).orderBy(asc(brand.name));
|
const data = await db.select().from(brands).orderBy(asc(brands.name));
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addBrand = async ( name: string) => {
|
export const addBrand = async ( name: string) => {
|
||||||
await db.insert(brand).values({
|
await db.insert(brands).values({
|
||||||
name: name,
|
name: name,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteBrand = async (id: number) => {
|
export const deleteBrand = async (id: number) => {
|
||||||
"use server";
|
"use server";
|
||||||
await db.delete(brand).where(eq(brand.id, id));
|
await db.delete(brands).where(eq(brands.id, id));
|
||||||
revalidatePath("/Brands");
|
revalidatePath("/Brands");
|
||||||
};
|
};
|
||||||
|
|
||||||
export const editBrand = async (id: number, name: string) => {
|
export const editBrand = async (id: number, name: string) => {
|
||||||
await db
|
await db
|
||||||
.update(brand)
|
.update(brands)
|
||||||
.set({
|
.set({
|
||||||
name: name,
|
name: name,
|
||||||
})
|
})
|
||||||
.where(eq(brand.id, id));
|
.where(eq(brands.id, id));
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
};
|
};
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
import { eq, not , asc} from "drizzle-orm";
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { ComponentType } from "@db/schema/ComponentTypes";
|
import { componentType } from "@schemas/schema";
|
||||||
export const getData = async () => {
|
export const getData = async () => {
|
||||||
const data = await db.select().from(ComponentType).orderBy(asc(ComponentType.name));
|
const data = await db.select().from(componentType).orderBy(asc(componentType.name));
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { eq, not , asc} from "drizzle-orm";
|
import { eq, not , asc} from "drizzle-orm";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { manufacturer } from "@db/schema/Manufacturer";
|
import { manufacturer } from "@schemas/schema";
|
||||||
export const getData = async () => {
|
export const getData = async () => {
|
||||||
const data = await db.select().from(manufacturer).orderBy(asc(manufacturer.name));
|
const data = await db.select().from(manufacturer).orderBy(asc(manufacturer.name));
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
|
import { psa } from "@src/drizzle/schema/schema";
|
||||||
import { NextPage } from "next";
|
import { NextPage } from "next";
|
||||||
|
|
||||||
export default function ProductPage() {
|
|
||||||
|
export default function ProductPage(props:any) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4 pt-16 mx-auto max-w-screen-lg">
|
<div className="p-4 pt-16 mx-auto max-w-screen-lg">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
|
||||||
{/* Product Image */}
|
{/* Product Image */}
|
||||||
<div className="bg-white rounded-lg shadow-md p-4">
|
<div className="bg-white rounded-lg shadow-md p-4">
|
||||||
<img
|
<img
|
||||||
src="https://www.radianweapons.com/receivers/lower-receivers/gallery/LOWER_RECEIVERS-1_6_1.jpg"
|
src={props.imageUrl}
|
||||||
alt="Product Name"
|
alt="Product Name"
|
||||||
className="w-full h-auto rounded-lg"
|
className="w-full h-auto rounded-lg"
|
||||||
/>
|
/>
|
||||||
@@ -15,7 +18,7 @@ export default function ProductPage() {
|
|||||||
|
|
||||||
{/* Product Info */}
|
{/* Product Info */}
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-3xl font-bold mb-4">Product Name</h1>
|
<h1 className="text-3xl font-bold mb-4">{props.productName}</h1>
|
||||||
|
|
||||||
{/* Vendor Pricing Table */}
|
{/* Vendor Pricing Table */}
|
||||||
<div className="bg-white rounded-lg shadow-md p-4 mb-6">
|
<div className="bg-white rounded-lg shadow-md p-4 mb-6">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ChevronDownIcon } from "@heroicons/react/20/solid";
|
|||||||
import { PlusCircleIcon } from "@heroicons/react/20/solid";
|
import { PlusCircleIcon } from "@heroicons/react/20/solid";
|
||||||
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
export default async function SortTable(props: any) {
|
export default async function SortTable(props: any) {
|
||||||
return (
|
return (
|
||||||
@@ -96,7 +97,12 @@ export default async function SortTable(props: any) {
|
|||||||
title="Click to see details"
|
title="Click to see details"
|
||||||
className="hover:size-60"
|
className="hover:size-60"
|
||||||
></Image>
|
></Image>
|
||||||
<span className="pl-2"> {item.productName}</span>
|
<Link href={{
|
||||||
|
pathname: '/product',
|
||||||
|
query: {
|
||||||
|
data: item.uuid,
|
||||||
|
},
|
||||||
|
}}><span className="pl-2"> {item.productName}</span></Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-xs text-gray-900">
|
<td className="whitespace-nowrap px-3 py-4 text-xs text-gray-900">
|
||||||
{item.brandName}
|
{item.brandName}
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ const navigation = {
|
|||||||
{ name: 'Guides', href: '/Guides' },
|
{ name: 'Guides', href: '/Guides' },
|
||||||
],
|
],
|
||||||
about: [
|
about: [
|
||||||
{ name: 'About', href: '/site/About' },
|
{ name: 'About', href: '/About' },
|
||||||
{ name: 'Blog', href: '/site/Blog' },
|
{ name: 'Blog', href: '/Blog' },
|
||||||
{ name: 'Jobs', href: '/site/Jobs' },
|
{ name: 'Jobs', href: '/Jobs' },
|
||||||
{ name: 'Press', href: '/site/Press' },
|
{ name: 'Press', href: '/Press' },
|
||||||
{ name: 'Contact', href: '/site/Contact' },
|
{ name: 'Contact', href: '/Contact' },
|
||||||
],
|
],
|
||||||
legal: [
|
legal: [
|
||||||
{ name: 'Terms of service', href: '/site/TOS' },
|
{ name: 'Terms of service', href: '/TOS' },
|
||||||
{ name: 'Privacy policy', href: '/site/PP' },
|
{ name: 'Privacy policy', href: '/PP' },
|
||||||
{ name: 'Affiliate Disclosure', href: '/site/Disclosure' },
|
{ name: 'Affiliate Disclosure', href: '/Disclosure' },
|
||||||
],
|
],
|
||||||
social: [
|
social: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import { users } from "@schemas/schema";
|
|
||||||
import { integer, pgTable, primaryKey, text } from "drizzle-orm/pg-core";
|
|
||||||
import type { AdapterAccountType } from "next-auth/adapters"
|
|
||||||
export const accounts = pgTable(
|
|
||||||
"account",
|
|
||||||
{
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
type: text("type").$type<AdapterAccountType>().notNull(),
|
|
||||||
provider: text("provider").notNull(),
|
|
||||||
providerAccountId: text("providerAccountId").notNull(),
|
|
||||||
refresh_token: text("refresh_token"),
|
|
||||||
access_token: text("access_token"),
|
|
||||||
expires_at: integer("expires_at"),
|
|
||||||
token_type: text("token_type"),
|
|
||||||
scope: text("scope"),
|
|
||||||
id_token: text("id_token"),
|
|
||||||
session_state: text("session_state"),
|
|
||||||
},
|
|
||||||
(account) => ({
|
|
||||||
compoundKey: primaryKey({
|
|
||||||
columns: [account.provider, account.providerAccountId],
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { numeric, pgTable, text, uuid } from "drizzle-orm/pg-core";
|
|
||||||
|
|
||||||
export const aeroPrecision = pgTable("aero_precision", {
|
|
||||||
sku: text().primaryKey().notNull(),
|
|
||||||
manufacturerId: text("manufacturer_id"),
|
|
||||||
brandName: text("brand_name"),
|
|
||||||
productName: text("product_name"),
|
|
||||||
longDescription: text("long_description"),
|
|
||||||
shortDescription: text("short_description"),
|
|
||||||
department: text(),
|
|
||||||
category: text(),
|
|
||||||
subcategory: text(),
|
|
||||||
thumbUrl: text("thumb_url"),
|
|
||||||
imageUrl: text("image_url"),
|
|
||||||
buyLink: text("buy_link"),
|
|
||||||
keywords: text(),
|
|
||||||
reviews: text(),
|
|
||||||
retailPrice: numeric("retail_price"),
|
|
||||||
salePrice: numeric("sale_price"),
|
|
||||||
brandPageLink: text("brand_page_link"),
|
|
||||||
brandLogoImage: text("brand_logo_image"),
|
|
||||||
productPageViewTracking: text("product_page_view_tracking"),
|
|
||||||
variantsXml: text("variants_xml"),
|
|
||||||
mediumImageUrl: text("medium_image_url"),
|
|
||||||
productContentWidget: text("product_content_widget"),
|
|
||||||
googleCategorization: text("google_categorization"),
|
|
||||||
itemBasedCommission: text("item_based_commission"),
|
|
||||||
uuid: uuid().defaultRandom(),
|
|
||||||
});
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { boolean, integer, pgTable, primaryKey, text } from "drizzle-orm/pg-core";
|
|
||||||
import { users } from '@schemas/schema'
|
|
||||||
export const authenticators = pgTable(
|
|
||||||
"authenticator",
|
|
||||||
{
|
|
||||||
credentialID: text("credentialID").notNull().unique(),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
providerAccountId: text("providerAccountId").notNull(),
|
|
||||||
credentialPublicKey: text("credentialPublicKey").notNull(),
|
|
||||||
counter: integer("counter").notNull(),
|
|
||||||
credentialDeviceType: text("credentialDeviceType").notNull(),
|
|
||||||
credentialBackedUp: boolean("credentialBackedUp").notNull(),
|
|
||||||
transports: text("transports"),
|
|
||||||
},
|
|
||||||
(authenticator) => ({
|
|
||||||
compositePK: primaryKey({
|
|
||||||
columns: [authenticator.userId, authenticator.credentialID],
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const brand = pgTable("brands", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "brands_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
name: varchar({length:100}).notNull(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, text, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const Build = pgTable("builds", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "build_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
account_id: integer().notNull(),
|
|
||||||
name: varchar({length:255}).notNull(),
|
|
||||||
description: text(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, text, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const BuildComponent = pgTable("builds_components", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "build_components_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
build_id: integer().notNull(),
|
|
||||||
product_id: integer().notNull(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const Category = pgTable("categories", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "categories_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom(),
|
|
||||||
name: varchar({length: 100}).notNull(),
|
|
||||||
parent_category_id: integer(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, text,uuid} from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const compartment = pgTable("compartment", {
|
|
||||||
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
||||||
name: varchar({ length: 100 }).notNull(),
|
|
||||||
description: varchar({ length: 300 }),
|
|
||||||
...timestamps
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, uuid} from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const ComponentType = pgTable("component_type", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "component_type_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
name: varchar({length: 100}).notNull(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, text, doublePrecision, timestamp } from "drizzle-orm/pg-core"
|
|
||||||
import { sql } from "drizzle-orm"
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
|
|
||||||
export const LipseyCatalog = pgTable("lipseycatalog", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "lipseycatalog_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
itemno: varchar({ length: 20 }).notNull(),
|
|
||||||
description1: text(),
|
|
||||||
description2: text(),
|
|
||||||
upc: varchar({ length: 20 }),
|
|
||||||
manufacturermodelno: varchar({ length: 30 }),
|
|
||||||
msrp: doublePrecision(),
|
|
||||||
model: text(),
|
|
||||||
calibergauge: text(),
|
|
||||||
manufacturer: text(),
|
|
||||||
type: text(),
|
|
||||||
action: text(),
|
|
||||||
barrellength: text(),
|
|
||||||
capacity: text(),
|
|
||||||
finish: text(),
|
|
||||||
overalllength: text(),
|
|
||||||
receiver: text(),
|
|
||||||
safety: text(),
|
|
||||||
sights: text(),
|
|
||||||
stockframegrips: text(),
|
|
||||||
magazine: text(),
|
|
||||||
weight: text(),
|
|
||||||
imagename: text(),
|
|
||||||
chamber: text(),
|
|
||||||
drilledandtapped: text(),
|
|
||||||
rateoftwist: text(),
|
|
||||||
itemtype: text(),
|
|
||||||
additionalfeature1: text(),
|
|
||||||
additionalfeature2: text(),
|
|
||||||
additionalfeature3: text(),
|
|
||||||
shippingweight: text(),
|
|
||||||
boundbookmanufacturer: text(),
|
|
||||||
boundbookmodel: text(),
|
|
||||||
boundbooktype: text(),
|
|
||||||
nfathreadpattern: text(),
|
|
||||||
nfaattachmentmethod: text(),
|
|
||||||
nfabaffletype: text(),
|
|
||||||
silencercanbedisassembled: text(),
|
|
||||||
silencerconstructionmaterial: text(),
|
|
||||||
nfadbreduction: text(),
|
|
||||||
silenceroutsidediameter: text(),
|
|
||||||
nfaform3Caliber: text(),
|
|
||||||
opticmagnification: text(),
|
|
||||||
maintubesize: text(),
|
|
||||||
adjustableobjective: text(),
|
|
||||||
objectivesize: text(),
|
|
||||||
opticadjustments: text(),
|
|
||||||
illuminatedreticle: text(),
|
|
||||||
reticle: text(),
|
|
||||||
exclusive: text(),
|
|
||||||
quantity: varchar({ length: 10 }).default(sql`NULL`),
|
|
||||||
allocated: text(),
|
|
||||||
onsale: text(),
|
|
||||||
price: doublePrecision(),
|
|
||||||
currentprice: doublePrecision(),
|
|
||||||
retailmap: doublePrecision(),
|
|
||||||
fflrequired: text(),
|
|
||||||
sotrequired: text(),
|
|
||||||
exclusivetype: text(),
|
|
||||||
scopecoverincluded: text(),
|
|
||||||
special: text(),
|
|
||||||
sightstype: text(),
|
|
||||||
case: text(),
|
|
||||||
choke: text(),
|
|
||||||
dbreduction: text(),
|
|
||||||
family: text(),
|
|
||||||
finishtype: text(),
|
|
||||||
frame: text(),
|
|
||||||
griptype: varchar({ length: 30 }),
|
|
||||||
handgunslidematerial: text(),
|
|
||||||
countryoforigin: varchar({ length: 4 }),
|
|
||||||
itemlength: text(),
|
|
||||||
itemwidth: text(),
|
|
||||||
itemheight: text(),
|
|
||||||
packagelength: doublePrecision(),
|
|
||||||
packagewidth: doublePrecision(),
|
|
||||||
packageheight: doublePrecision(),
|
|
||||||
itemgroup: varchar({ length: 40 }),
|
|
||||||
...timestamps
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, uuid} from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const manufacturer = pgTable("manufacturer", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "manufacturer_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
name: varchar({length:100}).notNull(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, text, decimal } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const Product = pgTable("products", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "products_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
name: varchar({length: 255 }).notNull(),
|
|
||||||
description: text().notNull(),
|
|
||||||
price: decimal().notNull(),
|
|
||||||
reseller_id: integer().notNull(),
|
|
||||||
category_id: integer().notNull(),
|
|
||||||
stock_qty: integer().default(0),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const Product_feed = pgTable("product_feeds", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "productfeeds_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
reseller_id: integer().notNull(),
|
|
||||||
feed_url: varchar({ length:255 }).notNull(),
|
|
||||||
last_update: timestamp(),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
import { pgTable, integer, varchar, text, decimal, uuid, real } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const psa = pgTable("psa", {
|
|
||||||
sku: varchar("SKU", { length: 50 }),
|
|
||||||
manufacturerId: varchar("MANUFACTURER_ID", { length: 50 }),
|
|
||||||
brandName: varchar("BRAND_NAME", { length: 50 }),
|
|
||||||
productName: varchar("PRODUCT_NAME", { length: 255 }),
|
|
||||||
longDescription: text("LONG_DESCRIPTION"),
|
|
||||||
shortDescription: varchar("SHORT_DESCRIPTION", { length: 50 }),
|
|
||||||
department: varchar("DEPARTMENT", { length: 50 }),
|
|
||||||
category: varchar("CATEGORY", { length: 50 }),
|
|
||||||
subcategory: varchar("SUBCATEGORY", { length: 50 }),
|
|
||||||
thumbUrl: varchar("THUMB_URL", { length: 50 }),
|
|
||||||
imageUrl: varchar("IMAGE_URL", { length: 50 }),
|
|
||||||
buyLink: varchar("BUY_LINK", { length: 128 }),
|
|
||||||
keywords: varchar("KEYWORDS", { length: 50 }),
|
|
||||||
reviews: varchar("REVIEWS", { length: 50 }),
|
|
||||||
retailPrice: real("RETAIL_PRICE"),
|
|
||||||
salePrice: real("SALE_PRICE"),
|
|
||||||
brandPageLink: varchar("BRAND_PAGE_LINK", { length: 50 }),
|
|
||||||
brandLogoImage: varchar("BRAND_LOGO_IMAGE", { length: 50 }),
|
|
||||||
productPageViewTracking: varchar("PRODUCT_PAGE_VIEW_TRACKING", { length: 256 }),
|
|
||||||
parentGroupId: varchar("PARENT_GROUP_ID", { length: 50 }),
|
|
||||||
fineline: varchar("FINELINE", { length: 50 }),
|
|
||||||
superfineline: varchar("SUPERFINELINE", { length: 200 }),
|
|
||||||
modelnumber: varchar("MODELNUMBER", { length: 50 }),
|
|
||||||
caliber: varchar("CALIBER", { length: 200 }),
|
|
||||||
upc: varchar("UPC", { length: 100 }),
|
|
||||||
mediumImageUrl: varchar("MEDIUM_IMAGE_URL", { length: 50 }),
|
|
||||||
productContentWidget: varchar("PRODUCT_CONTENT_WIDGET", { length: 256 }),
|
|
||||||
googleCategorization: varchar("GOOGLE_CATEGORIZATION", { length: 50 }),
|
|
||||||
itemBasedCommission: varchar("ITEM_BASED_COMMISSION", { length: 50 }),
|
|
||||||
uuid: uuid().defaultRandom(),
|
|
||||||
});
|
|
||||||
export default psa;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { pgTable, integer, varchar, uuid } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { timestamps } from "../../drizzle/schema/helpers/columns.helpers";
|
|
||||||
|
|
||||||
export const Reseller = pgTable("bal_resellers", {
|
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "resellers_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
uuid: uuid().defaultRandom().unique(),
|
|
||||||
name: varchar({ length: 100 }).notNull(),
|
|
||||||
website_url: varchar({ length: 255 }),
|
|
||||||
contact_email: varchar({length: 100}),
|
|
||||||
...timestamps
|
|
||||||
})
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
||||||
import {users} from '@schemas/schema';
|
|
||||||
export const sessions = pgTable("session", {
|
|
||||||
sessionToken: text("sessionToken").primaryKey(),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
expires: timestamp("expires", { mode: "date" }).notNull(),
|
|
||||||
})
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { integer, varchar, pgTable } from "drizzle-orm/pg-core";
|
|
||||||
|
|
||||||
export const State = pgTable("states", {
|
|
||||||
id: integer().primaryKey().generatedByDefaultAsIdentity({ name: "states_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
|
||||||
state: varchar({ length: 50 }),
|
|
||||||
abbreviation: varchar({ length: 50 }),
|
|
||||||
});
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { bigserial, boolean, check, date, pgTable, text, timestamp, unique, uuid, varchar } from "drizzle-orm/pg-core";
|
|
||||||
|
|
||||||
export const User = pgTable("users", {
|
|
||||||
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
|
||||||
username: varchar({ length: 50 }).notNull(),
|
|
||||||
email: varchar({ length: 255 }).notNull(),
|
|
||||||
passwordHash: varchar("password_hash", { length: 255 }).notNull(),
|
|
||||||
firstName: varchar("first_name", { length: 50 }),
|
|
||||||
lastName: varchar("last_name", { length: 50 }),
|
|
||||||
profilePicture: varchar("profile_picture", { length: 255 }),
|
|
||||||
dateOfBirth: date("date_of_birth"),
|
|
||||||
phoneNumber: varchar("phone_number", { length: 20 }),
|
|
||||||
createdAt: timestamp("created_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
|
|
||||||
updatedAt: timestamp("updated_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
|
|
||||||
isAdmin: boolean("is_admin").default(false),
|
|
||||||
lastLogin: timestamp("last_login", { mode: 'string' }),
|
|
||||||
emailVerified: boolean("email_verified").default(false),
|
|
||||||
buildPrivacySetting: text("build_privacy_setting").default('public'),
|
|
||||||
uuid: uuid().defaultRandom(),
|
|
||||||
}, (table) => {
|
|
||||||
return {
|
|
||||||
usersUsernameKey: unique("users_username_key").on(table.username),
|
|
||||||
usersEmailKey: unique("users_email_key").on(table.email),
|
|
||||||
usersBuildPrivacySettingCheck: check("users_build_privacy_setting_check", sql`build_privacy_setting = ANY (ARRAY['private'::text, 'public'::text])`),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const users = pgTable("user", {
|
|
||||||
id: text("id")
|
|
||||||
.primaryKey()
|
|
||||||
.$defaultFn(() => crypto.randomUUID()),
|
|
||||||
name: text("name"),
|
|
||||||
email: text("email").unique(),
|
|
||||||
emailVerified: timestamp("emailVerified", { mode: "date" }),
|
|
||||||
image: text("image"),
|
|
||||||
})
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { bigint, bigserial, foreignKey, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
||||||
import { sql } from "drizzle-orm";
|
|
||||||
import { users } from "./User";
|
|
||||||
|
|
||||||
export const userActivityLog = pgTable("user_activity_log", {
|
|
||||||
id: bigint({ mode: "bigint" }).primaryKey().generatedAlwaysAsIdentity({ name: "user_activity_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }).notNull(),
|
|
||||||
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
|
||||||
userId: bigint("user_id", { mode: "number" }).notNull(),
|
|
||||||
activity: text().notNull(),
|
|
||||||
timestamp: timestamp({ mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
|
|
||||||
}, (table) => {
|
|
||||||
return {
|
|
||||||
userActivityLogUserIdFkey: foreignKey({
|
|
||||||
columns: [table.userId],
|
|
||||||
foreignColumns: [users.id],
|
|
||||||
name: "user_activity_log_user_id_fkey"
|
|
||||||
}).onDelete("cascade"),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
|
|
||||||
|
|
||||||
export const verificationTokens = pgTable(
|
|
||||||
"verificationToken",
|
|
||||||
{
|
|
||||||
identifier: text("identifier").notNull(),
|
|
||||||
token: text("token").notNull(),
|
|
||||||
expires: timestamp("expires", { mode: "date" }).notNull(),
|
|
||||||
},
|
|
||||||
(verificationToken) => ({
|
|
||||||
compositePk: primaryKey({
|
|
||||||
columns: [verificationToken.identifier, verificationToken.token],
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { relations } from "drizzle-orm/relations";
|
|
||||||
import { } from "./LipseyCatalog";
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user