bunches of database modeling and drizzle setup

This commit is contained in:
2024-11-18 23:48:33 -05:00
parent 53d4e1211d
commit 1d27bcc20a
14 changed files with 2181 additions and 2 deletions

View File

@@ -0,0 +1,136 @@
-- 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);
*/

View File

@@ -0,0 +1,87 @@
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
);

View File

@@ -0,0 +1,560 @@
{
"id": "b292aaa5-0ccd-465e-aa88-fc01fe30739d",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.bal_accounts": {
"name": "bal_accounts",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"identity": {
"type": "always",
"name": "accountsid_seq",
"schema": "public",
"increment": "1",
"startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
"cache": "1",
"cycle": false
}
},
"first_name": {
"name": "first_name",
"type": "varchar(40)",
"primaryKey": false,
"notNull": false
},
"createdon": {
"name": "createdon",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.lipseycatalog": {
"name": "lipseycatalog",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"identity": {
"type": "always",
"name": "lipseycatalog_id_seq",
"schema": "public",
"increment": "1",
"startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
"cache": "1",
"cycle": false
}
},
"itemno": {
"name": "itemno",
"type": "varchar(20)",
"primaryKey": false,
"notNull": true
},
"description1": {
"name": "description1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description2": {
"name": "description2",
"type": "text",
"primaryKey": false,
"notNull": false
},
"upc": {
"name": "upc",
"type": "varchar(20)",
"primaryKey": false,
"notNull": false
},
"manufacturermodelno": {
"name": "manufacturermodelno",
"type": "varchar(30)",
"primaryKey": false,
"notNull": false
},
"msrp": {
"name": "msrp",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"model": {
"name": "model",
"type": "text",
"primaryKey": false,
"notNull": false
},
"calibergauge": {
"name": "calibergauge",
"type": "text",
"primaryKey": false,
"notNull": false
},
"manufacturer": {
"name": "manufacturer",
"type": "text",
"primaryKey": false,
"notNull": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": false
},
"action": {
"name": "action",
"type": "text",
"primaryKey": false,
"notNull": false
},
"barrellength": {
"name": "barrellength",
"type": "text",
"primaryKey": false,
"notNull": false
},
"capacity": {
"name": "capacity",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finish": {
"name": "finish",
"type": "text",
"primaryKey": false,
"notNull": false
},
"overalllength": {
"name": "overalllength",
"type": "text",
"primaryKey": false,
"notNull": false
},
"receiver": {
"name": "receiver",
"type": "text",
"primaryKey": false,
"notNull": false
},
"safety": {
"name": "safety",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sights": {
"name": "sights",
"type": "text",
"primaryKey": false,
"notNull": false
},
"stockframegrips": {
"name": "stockframegrips",
"type": "text",
"primaryKey": false,
"notNull": false
},
"magazine": {
"name": "magazine",
"type": "text",
"primaryKey": false,
"notNull": false
},
"weight": {
"name": "weight",
"type": "text",
"primaryKey": false,
"notNull": false
},
"imagename": {
"name": "imagename",
"type": "text",
"primaryKey": false,
"notNull": false
},
"chamber": {
"name": "chamber",
"type": "text",
"primaryKey": false,
"notNull": false
},
"drilledandtapped": {
"name": "drilledandtapped",
"type": "text",
"primaryKey": false,
"notNull": false
},
"rateoftwist": {
"name": "rateoftwist",
"type": "text",
"primaryKey": false,
"notNull": false
},
"itemtype": {
"name": "itemtype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"additionalfeature1": {
"name": "additionalfeature1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"additionalfeature2": {
"name": "additionalfeature2",
"type": "text",
"primaryKey": false,
"notNull": false
},
"additionalfeature3": {
"name": "additionalfeature3",
"type": "text",
"primaryKey": false,
"notNull": false
},
"shippingweight": {
"name": "shippingweight",
"type": "text",
"primaryKey": false,
"notNull": false
},
"boundbookmanufacturer": {
"name": "boundbookmanufacturer",
"type": "text",
"primaryKey": false,
"notNull": false
},
"boundbookmodel": {
"name": "boundbookmodel",
"type": "text",
"primaryKey": false,
"notNull": false
},
"boundbooktype": {
"name": "boundbooktype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"nfathreadpattern": {
"name": "nfathreadpattern",
"type": "text",
"primaryKey": false,
"notNull": false
},
"nfaattachmentmethod": {
"name": "nfaattachmentmethod",
"type": "text",
"primaryKey": false,
"notNull": false
},
"nfabaffletype": {
"name": "nfabaffletype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"silencercanbedisassembled": {
"name": "silencercanbedisassembled",
"type": "text",
"primaryKey": false,
"notNull": false
},
"silencerconstructionmaterial": {
"name": "silencerconstructionmaterial",
"type": "text",
"primaryKey": false,
"notNull": false
},
"nfadbreduction": {
"name": "nfadbreduction",
"type": "text",
"primaryKey": false,
"notNull": false
},
"silenceroutsidediameter": {
"name": "silenceroutsidediameter",
"type": "text",
"primaryKey": false,
"notNull": false
},
"nfaform3Caliber": {
"name": "nfaform3Caliber",
"type": "text",
"primaryKey": false,
"notNull": false
},
"opticmagnification": {
"name": "opticmagnification",
"type": "text",
"primaryKey": false,
"notNull": false
},
"maintubesize": {
"name": "maintubesize",
"type": "text",
"primaryKey": false,
"notNull": false
},
"adjustableobjective": {
"name": "adjustableobjective",
"type": "text",
"primaryKey": false,
"notNull": false
},
"objectivesize": {
"name": "objectivesize",
"type": "text",
"primaryKey": false,
"notNull": false
},
"opticadjustments": {
"name": "opticadjustments",
"type": "text",
"primaryKey": false,
"notNull": false
},
"illuminatedreticle": {
"name": "illuminatedreticle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"reticle": {
"name": "reticle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"exclusive": {
"name": "exclusive",
"type": "text",
"primaryKey": false,
"notNull": false
},
"quantity": {
"name": "quantity",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false,
"default": "NULL"
},
"allocated": {
"name": "allocated",
"type": "text",
"primaryKey": false,
"notNull": false
},
"onsale": {
"name": "onsale",
"type": "text",
"primaryKey": false,
"notNull": false
},
"price": {
"name": "price",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"currentprice": {
"name": "currentprice",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"retailmap": {
"name": "retailmap",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"fflrequired": {
"name": "fflrequired",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sotrequired": {
"name": "sotrequired",
"type": "text",
"primaryKey": false,
"notNull": false
},
"exclusivetype": {
"name": "exclusivetype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"scopecoverincluded": {
"name": "scopecoverincluded",
"type": "text",
"primaryKey": false,
"notNull": false
},
"special": {
"name": "special",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sightstype": {
"name": "sightstype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"case": {
"name": "case",
"type": "text",
"primaryKey": false,
"notNull": false
},
"choke": {
"name": "choke",
"type": "text",
"primaryKey": false,
"notNull": false
},
"dbreduction": {
"name": "dbreduction",
"type": "text",
"primaryKey": false,
"notNull": false
},
"family": {
"name": "family",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finishtype": {
"name": "finishtype",
"type": "text",
"primaryKey": false,
"notNull": false
},
"frame": {
"name": "frame",
"type": "text",
"primaryKey": false,
"notNull": false
},
"griptype": {
"name": "griptype",
"type": "varchar(30)",
"primaryKey": false,
"notNull": false
},
"handgunslidematerial": {
"name": "handgunslidematerial",
"type": "text",
"primaryKey": false,
"notNull": false
},
"countryoforigin": {
"name": "countryoforigin",
"type": "varchar(4)",
"primaryKey": false,
"notNull": false
},
"itemlength": {
"name": "itemlength",
"type": "text",
"primaryKey": false,
"notNull": false
},
"itemwidth": {
"name": "itemwidth",
"type": "text",
"primaryKey": false,
"notNull": false
},
"itemheight": {
"name": "itemheight",
"type": "text",
"primaryKey": false,
"notNull": false
},
"packagelength": {
"name": "packagelength",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"packagewidth": {
"name": "packagewidth",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"packageheight": {
"name": "packageheight",
"type": "double precision",
"primaryKey": false,
"notNull": false
},
"itemgroup": {
"name": "itemgroup",
"type": "varchar(40)",
"primaryKey": false,
"notNull": false
},
"createdon": {
"name": "createdon",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -0,0 +1,20 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1731960469559,
"tag": "0000_right_arclight",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1731986158709,
"tag": "0001_sweet_night_nurse",
"breakpoints": true
}
]
}

View File