mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
auth aint working, trying new version
This commit is contained in:
1
.env.local
Normal file
1
.env.local
Normal file
@@ -0,0 +1 @@
|
|||||||
|
AUTH_SECRET="a73X70xifFO5+V9oQ+/NKDDTgA4dsuWWxvFX6T1v1ns=" # Added by `npx auth`. Read more: https://cli.authjs.dev
|
||||||
@@ -2,15 +2,15 @@ import NextAuth from "next-auth"
|
|||||||
import Google from "next-auth/providers/google"
|
import Google from "next-auth/providers/google"
|
||||||
import { DrizzleAdapter } from "@auth/drizzle-adapter"
|
import { DrizzleAdapter } from "@auth/drizzle-adapter"
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import { users, account, session, verificationToken } from "@schemas/schema";
|
import { users, accounts, sessions, verificationTokens } from "@schemas/schema";
|
||||||
|
|
||||||
|
|
||||||
export const { handlers, auth } = NextAuth({
|
export const { handlers, auth } = NextAuth({
|
||||||
adapter: DrizzleAdapter(db, {
|
adapter: DrizzleAdapter(db, {
|
||||||
usersTable: users,
|
usersTable: users,
|
||||||
accountsTable: account,
|
accountsTable: accounts,
|
||||||
sessionsTable: session,
|
sessionsTable: sessions,
|
||||||
verificationTokensTable: verificationToken,
|
verificationTokensTable: verificationTokens,
|
||||||
}),
|
}),
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
5
src/auth.js
Normal file
5
src/auth.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import NextAuth from "next-auth"
|
||||||
|
|
||||||
|
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||||
import {user} from '@schemas/schema';
|
import {users} from '@schemas/schema';
|
||||||
export const sessions = pgTable("session", {
|
export const sessions = pgTable("session", {
|
||||||
sessionToken: text("sessionToken").primaryKey(),
|
sessionToken: text("sessionToken").primaryKey(),
|
||||||
userId: text("userId")
|
userId: text("userId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
expires: timestamp("expires", { mode: "date" }).notNull(),
|
expires: timestamp("expires", { mode: "date" }).notNull(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
-- 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 "_prisma_migrations" (
|
|
||||||
"id" varchar(36) PRIMARY KEY NOT NULL,
|
|
||||||
"checksum" varchar(64) NOT NULL,
|
|
||||||
"finished_at" timestamp with time zone,
|
|
||||||
"migration_name" varchar(255) NOT NULL,
|
|
||||||
"logs" text,
|
|
||||||
"rolled_back_at" timestamp with time zone,
|
|
||||||
"started_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
"applied_steps_count" integer DEFAULT 0 NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE IF NOT EXISTS "User" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"email" text NOT NULL,
|
|
||||||
"name" text
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE IF NOT EXISTS "Post" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"createdAt" timestamp(3) DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updatedAt" timestamp(3) NOT NULL,
|
|
||||||
"title" text,
|
|
||||||
"content" text,
|
|
||||||
"published" boolean DEFAULT false NOT NULL,
|
|
||||||
"authorId" integer NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE IF NOT EXISTS "Profile" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"bio" text,
|
|
||||||
"userId" integer NOT NULL
|
|
||||||
);
|
|
||||||
--> 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),
|
|
||||||
"createdon" timestamp
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
DO $$ BEGIN
|
|
||||||
ALTER TABLE "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "public"."User"("id") ON DELETE restrict ON UPDATE cascade;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END $$;
|
|
||||||
--> statement-breakpoint
|
|
||||||
DO $$ BEGIN
|
|
||||||
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE restrict ON UPDATE cascade;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END $$;
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS "User_email_key" ON "User" USING btree ("email" text_ops);--> statement-breakpoint
|
|
||||||
CREATE INDEX IF NOT EXISTS "User_id_idx" ON "User" USING btree ("id" int4_ops);--> statement-breakpoint
|
|
||||||
CREATE INDEX IF NOT EXISTS "Post_id_idx" ON "Post" USING btree ("id" int4_ops);--> statement-breakpoint
|
|
||||||
CREATE INDEX IF NOT EXISTS "Profile_id_idx" ON "Profile" USING btree ("id" int4_ops);--> statement-breakpoint
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS "Profile_userId_key" ON "Profile" USING btree ("userId" int4_ops);
|
|
||||||
*/
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS "bal_accounts" (
|
|
||||||
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "accountsid_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
|
||||||
"first_name" varchar(40),
|
|
||||||
"createdon" timestamp
|
|
||||||
);
|
|
||||||
--> 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),
|
|
||||||
"createdon" timestamp
|
|
||||||
);
|
|
||||||
@@ -16,7 +16,7 @@ export const products = pgTable("products", {
|
|||||||
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
deletedAt: timestamp("deleted_at", { mode: 'string' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const users = pgTable("users", {
|
export const users = pgTable("users-keep", {
|
||||||
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
||||||
username: varchar({ length: 50 }).notNull(),
|
username: varchar({ length: 50 }).notNull(),
|
||||||
email: varchar({ length: 255 }).notNull(),
|
email: varchar({ length: 255 }).notNull(),
|
||||||
@@ -66,7 +66,7 @@ export const productFeeds = pgTable("product_feeds", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const user = pgTable("user", {
|
export const user = pgTable("users", {
|
||||||
id: text().primaryKey().notNull(),
|
id: text().primaryKey().notNull(),
|
||||||
name: text(),
|
name: text(),
|
||||||
email: text(),
|
email: text(),
|
||||||
@@ -113,7 +113,7 @@ export const manufacturer = pgTable("manufacturer", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const session = pgTable("session", {
|
export const session = pgTable("sessions", {
|
||||||
sessionToken: text().primaryKey().notNull(),
|
sessionToken: text().primaryKey().notNull(),
|
||||||
userId: text().notNull(),
|
userId: text().notNull(),
|
||||||
expires: timestamp({ mode: 'string' }).notNull(),
|
expires: timestamp({ mode: 'string' }).notNull(),
|
||||||
@@ -336,7 +336,7 @@ export const balResellers = pgTable("bal_resellers", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const verificationToken = pgTable("verificationToken", {
|
export const verificationToken = pgTable("verificationTokens", {
|
||||||
identifier: text().notNull(),
|
identifier: text().notNull(),
|
||||||
token: text().notNull(),
|
token: text().notNull(),
|
||||||
expires: timestamp({ mode: 'string' }).notNull(),
|
expires: timestamp({ mode: 'string' }).notNull(),
|
||||||
@@ -367,7 +367,7 @@ export const authenticator = pgTable("authenticator", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const account = pgTable("account", {
|
export const account = pgTable("accounts", {
|
||||||
userId: text().notNull(),
|
userId: text().notNull(),
|
||||||
type: text().notNull(),
|
type: text().notNull(),
|
||||||
provider: text().notNull(),
|
provider: text().notNull(),
|
||||||
@@ -1,349 +0,0 @@
|
|||||||
-- 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 $$;
|
|
||||||
|
|
||||||
*/
|
|
||||||
@@ -1,13 +1,3 @@
|
|||||||
import { relations } from "drizzle-orm/relations";
|
import { relations } from "drizzle-orm/relations";
|
||||||
import { user, authenticator } from "./schema";
|
import { } 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),
|
|
||||||
}));
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pgTable, integer, varchar, text, numeric, timestamp, unique, check, bigserial, date, boolean, uuid, bigint, real, doublePrecision, primaryKey, foreignKey } from "drizzle-orm/pg-core"
|
import { pgTable, integer, varchar, text, numeric, timestamp, unique, check, bigserial, date, boolean, uuid, bigint, real, doublePrecision, primaryKey } from "drizzle-orm/pg-core"
|
||||||
import { sql } from "drizzle-orm"
|
import { sql } from "drizzle-orm"
|
||||||
|
|
||||||
|
|
||||||
@@ -17,6 +17,16 @@ export const products = pgTable("products", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const users = pgTable("users", {
|
export const users = pgTable("users", {
|
||||||
|
id: text("id")
|
||||||
|
.primaryKey()
|
||||||
|
.$defaultFn(() => crypto.randomUUID()),
|
||||||
|
name: text("name"),
|
||||||
|
email: text("email").unique(),
|
||||||
|
emailVerified: timestamp("emailVerified", { mode: "date" }),
|
||||||
|
image: text("image"),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const userskeep = pgTable("users-keep", {
|
||||||
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
||||||
username: varchar({ length: 50 }).notNull(),
|
username: varchar({ length: 50 }).notNull(),
|
||||||
email: varchar({ length: 255 }).notNull(),
|
email: varchar({ length: 255 }).notNull(),
|
||||||
@@ -66,18 +76,6 @@ export const productFeeds = pgTable("product_feeds", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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", {
|
export const userActivityLog = pgTable("user_activity_log", {
|
||||||
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
// 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 }),
|
id: bigint({ mode: "number" }).primaryKey().generatedAlwaysAsIdentity({ name: "user_activity_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||||
@@ -100,6 +98,12 @@ export const brands = pgTable("brands", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const sessions = pgTable("sessions", {
|
||||||
|
sessionToken: text().primaryKey().notNull(),
|
||||||
|
userId: text().notNull(),
|
||||||
|
expires: timestamp({ mode: 'string' }).notNull(),
|
||||||
|
});
|
||||||
|
|
||||||
export const manufacturer = pgTable("manufacturer", {
|
export const manufacturer = pgTable("manufacturer", {
|
||||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "manufacturer_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "manufacturer_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||||
name: varchar({ length: 100 }).notNull(),
|
name: varchar({ length: 100 }).notNull(),
|
||||||
@@ -113,12 +117,6 @@ export const manufacturer = pgTable("manufacturer", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const session = pgTable("session", {
|
|
||||||
sessionToken: text().primaryKey().notNull(),
|
|
||||||
userId: text().notNull(),
|
|
||||||
expires: timestamp({ mode: 'string' }).notNull(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const states = pgTable("states", {
|
export const states = pgTable("states", {
|
||||||
id: integer().primaryKey().generatedByDefaultAsIdentity({ name: "states_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
id: integer().primaryKey().generatedByDefaultAsIdentity({ name: "states_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||||
state: varchar({ length: 50 }),
|
state: varchar({ length: 50 }),
|
||||||
@@ -336,7 +334,7 @@ export const balResellers = pgTable("bal_resellers", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const verificationToken = pgTable("verificationToken", {
|
export const verificationTokens = pgTable("verificationTokens", {
|
||||||
identifier: text().notNull(),
|
identifier: text().notNull(),
|
||||||
token: text().notNull(),
|
token: text().notNull(),
|
||||||
expires: timestamp({ mode: 'string' }).notNull(),
|
expires: timestamp({ mode: 'string' }).notNull(),
|
||||||
@@ -357,17 +355,12 @@ export const authenticator = pgTable("authenticator", {
|
|||||||
transports: text(),
|
transports: text(),
|
||||||
}, (table) => {
|
}, (table) => {
|
||||||
return {
|
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"}),
|
authenticatorUserIdCredentialIdPk: primaryKey({ columns: [table.credentialId, table.userId], name: "authenticator_userId_credentialID_pk"}),
|
||||||
authenticatorCredentialIdUnique: unique("authenticator_credentialID_unique").on(table.credentialId),
|
authenticatorCredentialIdUnique: unique("authenticator_credentialID_unique").on(table.credentialId),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const account = pgTable("account", {
|
export const accounts = pgTable("accounts", {
|
||||||
userId: text().notNull(),
|
userId: text().notNull(),
|
||||||
type: text().notNull(),
|
type: text().notNull(),
|
||||||
provider: text().notNull(),
|
provider: text().notNull(),
|
||||||
|
|||||||
Reference in New Issue
Block a user