mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 10:46:44 -05:00
moved schema to a single file
This commit is contained in:
349
src/drizzle/schema/0000_stiff_odin.sql
Normal file
349
src/drizzle/schema/0000_stiff_odin.sql
Normal file
@@ -0,0 +1,349 @@
|
||||
-- Current sql file was generated after introspecting the database
|
||||
-- If you want to run this migration please uncomment this code before executing migrations
|
||||
/*
|
||||
CREATE TABLE IF NOT EXISTS "products" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(255) NOT NULL,
|
||||
"description" text NOT NULL,
|
||||
"price" numeric NOT NULL,
|
||||
"reseller_id" integer NOT NULL,
|
||||
"category_id" integer NOT NULL,
|
||||
"stock_qty" integer DEFAULT 0,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "users" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"username" varchar(50) NOT NULL,
|
||||
"email" varchar(255) NOT NULL,
|
||||
"password_hash" varchar(255) NOT NULL,
|
||||
"first_name" varchar(50),
|
||||
"last_name" varchar(50),
|
||||
"profile_picture" varchar(255),
|
||||
"date_of_birth" date,
|
||||
"phone_number" varchar(20),
|
||||
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"is_admin" boolean DEFAULT false,
|
||||
"last_login" timestamp,
|
||||
"email_verified" boolean DEFAULT false,
|
||||
"build_privacy_setting" text DEFAULT 'public',
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "users_username_key" UNIQUE("username"),
|
||||
CONSTRAINT "users_email_key" UNIQUE("email"),
|
||||
CONSTRAINT "users_build_privacy_setting_check" CHECK (build_privacy_setting = ANY (ARRAY['private'::text, 'public'::text]))
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "categories" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "categories_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(100) NOT NULL,
|
||||
"parent_category_id" integer,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "product_feeds" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "productfeeds_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"reseller_id" integer NOT NULL,
|
||||
"feed_url" varchar(255) NOT NULL,
|
||||
"last_update" timestamp,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "product_feeds_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "user" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"name" text,
|
||||
"email" text,
|
||||
"emailVerified" timestamp,
|
||||
"image" text,
|
||||
CONSTRAINT "user_email_unique" UNIQUE("email")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "user_activity_log" (
|
||||
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "user_activity_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"user_id" bigint NOT NULL,
|
||||
"activity" text NOT NULL,
|
||||
"timestamp" timestamp DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "brands" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "brands_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(100) NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "brands_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "manufacturer" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "manufacturer_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(100) NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "manufacturer_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "session" (
|
||||
"sessionToken" text PRIMARY KEY NOT NULL,
|
||||
"userId" text NOT NULL,
|
||||
"expires" timestamp NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "states" (
|
||||
"id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "states_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"state" varchar(50),
|
||||
"abbreviation" varchar(50)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "component_type" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "component_type_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(100) NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "component_type_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "aero_precision" (
|
||||
"sku" text PRIMARY KEY NOT NULL,
|
||||
"manufacturer_id" text,
|
||||
"brand_name" text,
|
||||
"product_name" text,
|
||||
"long_description" text,
|
||||
"short_description" text,
|
||||
"department" text,
|
||||
"category" text,
|
||||
"subcategory" text,
|
||||
"thumb_url" text,
|
||||
"image_url" text,
|
||||
"buy_link" text,
|
||||
"keywords" text,
|
||||
"reviews" text,
|
||||
"retail_price" numeric,
|
||||
"sale_price" numeric,
|
||||
"brand_page_link" text,
|
||||
"brand_logo_image" text,
|
||||
"product_page_view_tracking" text,
|
||||
"variants_xml" text,
|
||||
"medium_image_url" text,
|
||||
"product_content_widget" text,
|
||||
"google_categorization" text,
|
||||
"item_based_commission" text,
|
||||
"uuid" uuid DEFAULT gen_random_uuid()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "compartment" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"name" varchar(100) NOT NULL,
|
||||
"description" varchar(300),
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "builds" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "build_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"account_id" integer NOT NULL,
|
||||
"name" varchar(255) NOT NULL,
|
||||
"description" text,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "builds_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "psa" (
|
||||
"SKU" varchar(50),
|
||||
"MANUFACTURER_ID" varchar(50),
|
||||
"BRAND_NAME" varchar(50),
|
||||
"PRODUCT_NAME" varchar(255),
|
||||
"LONG_DESCRIPTION" text,
|
||||
"SHORT_DESCRIPTION" varchar(50),
|
||||
"DEPARTMENT" varchar(50),
|
||||
"CATEGORY" varchar(50),
|
||||
"SUBCATEGORY" varchar(50),
|
||||
"THUMB_URL" varchar(50),
|
||||
"IMAGE_URL" varchar(50),
|
||||
"BUY_LINK" varchar(128),
|
||||
"KEYWORDS" varchar(50),
|
||||
"REVIEWS" varchar(50),
|
||||
"RETAIL_PRICE" real,
|
||||
"SALE_PRICE" real,
|
||||
"BRAND_PAGE_LINK" varchar(50),
|
||||
"BRAND_LOGO_IMAGE" varchar(50),
|
||||
"PRODUCT_PAGE_VIEW_TRACKING" varchar(256),
|
||||
"PARENT_GROUP_ID" varchar(50),
|
||||
"FINELINE" varchar(50),
|
||||
"SUPERFINELINE" varchar(200),
|
||||
"MODELNUMBER" varchar(50),
|
||||
"CALIBER" varchar(200),
|
||||
"UPC" varchar(100),
|
||||
"MEDIUM_IMAGE_URL" varchar(50),
|
||||
"PRODUCT_CONTENT_WIDGET" varchar(256),
|
||||
"GOOGLE_CATEGORIZATION" varchar(50),
|
||||
"ITEM_BASED_COMMISSION" varchar(50),
|
||||
"uuid" uuid DEFAULT gen_random_uuid()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "lipseycatalog" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "lipseycatalog_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"itemno" varchar(20) NOT NULL,
|
||||
"description1" text,
|
||||
"description2" text,
|
||||
"upc" varchar(20),
|
||||
"manufacturermodelno" varchar(30),
|
||||
"msrp" double precision,
|
||||
"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(10) DEFAULT NULL,
|
||||
"allocated" text,
|
||||
"onsale" text,
|
||||
"price" double precision,
|
||||
"currentprice" double precision,
|
||||
"retailmap" double precision,
|
||||
"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(30),
|
||||
"handgunslidematerial" text,
|
||||
"countryoforigin" varchar(4),
|
||||
"itemlength" text,
|
||||
"itemwidth" text,
|
||||
"itemheight" text,
|
||||
"packagelength" double precision,
|
||||
"packagewidth" double precision,
|
||||
"packageheight" double precision,
|
||||
"itemgroup" varchar(40),
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "builds_components" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "build_components_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"build_id" integer NOT NULL,
|
||||
"product_id" integer NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "builds_components_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "bal_resellers" (
|
||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "resellers_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
||||
"name" varchar(100) NOT NULL,
|
||||
"website_url" varchar(255),
|
||||
"contact_email" varchar(100),
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp,
|
||||
"uuid" uuid DEFAULT gen_random_uuid(),
|
||||
CONSTRAINT "bal_resellers_uuid_unique" UNIQUE("uuid")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "verificationToken" (
|
||||
"identifier" text NOT NULL,
|
||||
"token" text NOT NULL,
|
||||
"expires" timestamp NOT NULL,
|
||||
CONSTRAINT "verificationToken_identifier_token_pk" PRIMARY KEY("identifier","token")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "authenticator" (
|
||||
"credentialID" text NOT NULL,
|
||||
"userId" text NOT NULL,
|
||||
"providerAccountId" text NOT NULL,
|
||||
"credentialPublicKey" text NOT NULL,
|
||||
"counter" integer NOT NULL,
|
||||
"credentialDeviceType" text NOT NULL,
|
||||
"credentialBackedUp" boolean NOT NULL,
|
||||
"transports" text,
|
||||
CONSTRAINT "authenticator_userId_credentialID_pk" PRIMARY KEY("credentialID","userId"),
|
||||
CONSTRAINT "authenticator_credentialID_unique" UNIQUE("credentialID")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "account" (
|
||||
"userId" text NOT NULL,
|
||||
"type" text NOT NULL,
|
||||
"provider" text NOT NULL,
|
||||
"providerAccountId" text NOT NULL,
|
||||
"refresh_token" text,
|
||||
"access_token" text,
|
||||
"expires_at" integer,
|
||||
"token_type" text,
|
||||
"scope" text,
|
||||
"id_token" text,
|
||||
"session_state" text,
|
||||
CONSTRAINT "account_provider_providerAccountId_pk" PRIMARY KEY("provider","providerAccountId")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "authenticator" ADD CONSTRAINT "authenticator_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
*/
|
||||
14
src/drizzle/schema/helpers/columns.helpers.ts
Normal file
14
src/drizzle/schema/helpers/columns.helpers.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { timestamp } from "drizzle-orm/pg-core";
|
||||
|
||||
// columns.helpers.ts
|
||||
export const timestamps = {
|
||||
updated_at: timestamp().defaultNow().notNull(),
|
||||
created_at: timestamp().defaultNow().notNull(),
|
||||
deleted_at: timestamp(),
|
||||
}
|
||||
|
||||
export const timestampsAllowNulls = {
|
||||
updated_at: timestamp().defaultNow(),
|
||||
created_at: timestamp().defaultNow(),
|
||||
deleted_at: timestamp(),
|
||||
}
|
||||
2174
src/drizzle/schema/meta/0000_snapshot.json
Normal file
2174
src/drizzle/schema/meta/0000_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
13
src/drizzle/schema/meta/_journal.json
Normal file
13
src/drizzle/schema/meta/_journal.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1734388473133,
|
||||
"tag": "0000_stiff_odin",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
13
src/drizzle/schema/relations.ts
Normal file
13
src/drizzle/schema/relations.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { relations } from "drizzle-orm/relations";
|
||||
import { user, authenticator } from "./schema";
|
||||
|
||||
export const authenticatorRelations = relations(authenticator, ({one}) => ({
|
||||
user: one(user, {
|
||||
fields: [authenticator.userId],
|
||||
references: [user.id]
|
||||
}),
|
||||
}));
|
||||
|
||||
export const userRelations = relations(user, ({many}) => ({
|
||||
authenticators: many(authenticator),
|
||||
}));
|
||||
386
src/drizzle/schema/schema.ts
Normal file
386
src/drizzle/schema/schema.ts
Normal file
@@ -0,0 +1,386 @@
|
||||
import { pgTable, integer, varchar, text, numeric, timestamp, unique, check, bigserial, date, boolean, uuid, bigint, real, doublePrecision, primaryKey, foreignKey } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
|
||||
|
||||
|
||||
export const products = 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: numeric().notNull(),
|
||||
resellerId: integer("reseller_id").notNull(),
|
||||
categoryId: integer("category_id").notNull(),
|
||||
stockQty: integer("stock_qty").default(0),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
});
|
||||
|
||||
export const users = 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 categories = pgTable("categories", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "categories_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
parentCategoryId: integer("parent_category_id"),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
});
|
||||
|
||||
export const productFeeds = pgTable("product_feeds", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "productfeeds_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
resellerId: integer("reseller_id").notNull(),
|
||||
feedUrl: varchar("feed_url", { length: 255 }).notNull(),
|
||||
lastUpdate: timestamp("last_update", { mode: 'string' }),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
productFeedsUuidUnique: unique("product_feeds_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
export const user = pgTable("user", {
|
||||
id: text().primaryKey().notNull(),
|
||||
name: text(),
|
||||
email: text(),
|
||||
emailVerified: timestamp({ mode: 'string' }),
|
||||
image: text(),
|
||||
}, (table) => {
|
||||
return {
|
||||
userEmailUnique: unique("user_email_unique").on(table.email),
|
||||
}
|
||||
});
|
||||
|
||||
export const userActivityLog = pgTable("user_activity_log", {
|
||||
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
||||
id: bigint({ mode: "number" }).primaryKey().generatedAlwaysAsIdentity({ name: "user_activity_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
// 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`),
|
||||
});
|
||||
|
||||
export const brands = pgTable("brands", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "brands_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
brandsUuidUnique: unique("brands_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
export const manufacturer = pgTable("manufacturer", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "manufacturer_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
manufacturerUuidUnique: unique("manufacturer_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
export const session = pgTable("session", {
|
||||
sessionToken: text().primaryKey().notNull(),
|
||||
userId: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
});
|
||||
|
||||
export const states = 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 }),
|
||||
});
|
||||
|
||||
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 }),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
componentTypeUuidUnique: unique("component_type_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
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(),
|
||||
});
|
||||
|
||||
export const compartment = pgTable("compartment", {
|
||||
id: uuid().defaultRandom().primaryKey().notNull(),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
description: varchar({ length: 300 }),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
});
|
||||
|
||||
export const builds = pgTable("builds", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "build_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
accountId: integer("account_id").notNull(),
|
||||
name: varchar({ length: 255 }).notNull(),
|
||||
description: text(),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
buildsUuidUnique: unique("builds_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
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 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 }),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
});
|
||||
|
||||
export const buildsComponents = pgTable("builds_components", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "build_components_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
buildId: integer("build_id").notNull(),
|
||||
productId: integer("product_id").notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
buildsComponentsUuidUnique: unique("builds_components_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
export const balResellers = pgTable("bal_resellers", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "resellers_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
name: varchar({ length: 100 }).notNull(),
|
||||
websiteUrl: varchar("website_url", { length: 255 }),
|
||||
contactEmail: varchar("contact_email", { length: 100 }),
|
||||
updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||
uuid: uuid().defaultRandom(),
|
||||
}, (table) => {
|
||||
return {
|
||||
balResellersUuidUnique: unique("bal_resellers_uuid_unique").on(table.uuid),
|
||||
}
|
||||
});
|
||||
|
||||
export const verificationToken = pgTable("verificationToken", {
|
||||
identifier: text().notNull(),
|
||||
token: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
}, (table) => {
|
||||
return {
|
||||
verificationTokenIdentifierTokenPk: primaryKey({ columns: [table.identifier, table.token], name: "verificationToken_identifier_token_pk"}),
|
||||
}
|
||||
});
|
||||
|
||||
export const authenticator = pgTable("authenticator", {
|
||||
credentialId: text().notNull(),
|
||||
userId: text().notNull(),
|
||||
providerAccountId: text().notNull(),
|
||||
credentialPublicKey: text().notNull(),
|
||||
counter: integer().notNull(),
|
||||
credentialDeviceType: text().notNull(),
|
||||
credentialBackedUp: boolean().notNull(),
|
||||
transports: text(),
|
||||
}, (table) => {
|
||||
return {
|
||||
authenticatorUserIdUserIdFk: foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [user.id],
|
||||
name: "authenticator_userId_user_id_fk"
|
||||
}).onDelete("cascade"),
|
||||
authenticatorUserIdCredentialIdPk: primaryKey({ columns: [table.credentialId, table.userId], name: "authenticator_userId_credentialID_pk"}),
|
||||
authenticatorCredentialIdUnique: unique("authenticator_credentialID_unique").on(table.credentialId),
|
||||
}
|
||||
});
|
||||
|
||||
export const account = pgTable("account", {
|
||||
userId: text().notNull(),
|
||||
type: text().notNull(),
|
||||
provider: text().notNull(),
|
||||
providerAccountId: text().notNull(),
|
||||
refreshToken: text("refresh_token"),
|
||||
accessToken: text("access_token"),
|
||||
expiresAt: integer("expires_at"),
|
||||
tokenType: text("token_type"),
|
||||
scope: text(),
|
||||
idToken: text("id_token"),
|
||||
sessionState: text("session_state"),
|
||||
}, (table) => {
|
||||
return {
|
||||
accountProviderProviderAccountIdPk: primaryKey({ columns: [table.provider, table.providerAccountId], name: "account_provider_providerAccountId_pk"}),
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user