mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
bunches of database modeling and drizzle setup
This commit is contained in:
3
src/db/index.ts
Normal file
3
src/db/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'dotenv/config';
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
const db = drizzle(process.env.DATABASE_URL!);
|
||||
7
src/db/schema.ts
Normal file
7
src/db/schema.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { integer, pgTable, varchar } from "drizzle-orm/pg-core";
|
||||
export const usersTable = pgTable("users", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||
name: varchar({ length: 255 }).notNull(),
|
||||
age: integer().notNull(),
|
||||
email: varchar({ length: 255 }).notNull().unique(),
|
||||
});
|
||||
10
src/db/schema/accounts.ts
Normal file
10
src/db/schema/accounts.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { pgTable, integer, varchar } from "drizzle-orm/pg-core";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { timestamps } from "./columns.helpers";
|
||||
|
||||
export const accounts = pgTable("bal_accounts", {
|
||||
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "accountsid_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
|
||||
first_name: varchar({ length: 40 }),
|
||||
last_name: varchar({ length: 40 }),
|
||||
...timestamps
|
||||
})
|
||||
14
src/db/schema/columns.helpers.ts
Normal file
14
src/db/schema/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(),
|
||||
}
|
||||
88
src/db/schema/lipseyCatalog.ts
Normal file
88
src/db/schema/lipseyCatalog.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { pgTable, integer, varchar, text, doublePrecision, timestamp } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
import { timestamps } from "./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
|
||||
});
|
||||
|
||||
;
|
||||
3
src/db/schema/relations.ts
Normal file
3
src/db/schema/relations.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { relations } from "drizzle-orm/relations";
|
||||
import { } from "./lipseyCatalog";
|
||||
|
||||
Reference in New Issue
Block a user