only give me all schema for drizzle orm with postgresql in diffrent different file like staff.ts,stock.ts etc
erp-system (5).zip
3 / 3
give me only shema for this project
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const staff = pgTable('staff', {
id: serial('id').primaryKey(),
firstName: text('first_name').notNull(),
lastName: text('last_name').notNull(),
email: text('email').notNull().unique(),
phoneNumber: text('phone_number'),
gender: text('gender'),
staffId: text('staff_id').notNull().unique(),
role: text('role'),
designation: text('designation'),
officialEmail: text('official_email').unique(),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Staff = typeof staff.$inferSelect;
export type NewStaff = typeof staff.$inferInsert;
import { pgTable, serial, text, integer, numeric } from 'drizzle-orm/pg-core';
export const stock = pgTable('stock', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
productId: text('product_id').notNull().unique(),
category: text('category'),
qtyPurchased: integer('qty_purchased'),
unitPrice: numeric('unit_price'),
totalAmount: numeric('total_amount'),
inStock: integer('in_stock'),
supplier: text('supplier'),
status: text('status'),
});
export type Stock = typeof stock.$inferSelect;
export type NewStock = typeof stock.$inferInsert;
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const memo = pgTable('memo', {
id: serial('id').primaryKey(),
title: text('title').notNull(),
sentFrom: text('sent_from'),
sentTo: text('sent_to'),
date: timestamp('date'),
attachment: text('attachment'),
type: text('type'),
message: text('message'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Memo = typeof memo.$inferSelect;
export type NewMemo = typeof memo.$inferInsert;
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const circular = pgTable('circular', {
id: serial('id').primaryKey(),
title: text('title').notNull(),
sentFrom: text('sent_from'),
sentTo: text('sent_to'),
date: timestamp('date'),
type: text('type'),
message: text('message'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Circular = typeof circular.$inferSelect;
export type NewCircular = typeof circular.$inferInsert;
import { pgTable, serial, text, numeric, timestamp } from 'drizzle-orm/pg-core';
export const procurement = pgTable('procurement', {
id: serial('id').primaryKey(),
item: text('item').notNull(),
quantity: integer('quantity'),
unitPrice: numeric('unit_price'),
totalPrice: numeric('total_price'),
date: timestamp('date'),
requestedBy: text('requested_by'),
sentTo: text('sent_to'),
status: text('status'),
attachment: text('attachment'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Procurement = typeof procurement.$inferSelect;
export type NewProcurement = typeof procurement.$inferInsert;
import { pgTable, serial, text, integer, numeric } from 'drizzle-orm/pg-core';
export const inventory = pgTable('inventory', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
productId: text('product_id').notNull().unique(),
category: text('category'),
qtyPurchased: integer('qty_purchased'),
unitPrice: numeric('unit_price'),
totalAmount: numeric('total_amount'),
inStock: integer('in_stock'),
supplier: text('supplier'),
status: text('status'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Inventory = typeof inventory.$inferSelect;
export type NewInventory = typeof inventory.$inferInsert;
import { pgTable, serial, text, integer, numeric, timestamp } from 'drizzle-orm/pg-core';
export const officeBudget = pgTable('office_budget', {
id: serial('id').primaryKey(),
budgetNo: text('budget_no').notNull().unique(),
budgetDescription: text('budget_description'),
budgetedAmount: numeric('budgeted_amount'),
actualAmount: numeric('actual_amount'),
variance: numeric('variance'),
date: timestamp('date'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type OfficeBudget = typeof officeBudget.$inferSelect;
export type NewOfficeBudget = typeof officeBudget.$inferInsert;
import { pgTable, serial, text, integer, numeric, timestamp } from 'drizzle-orm/pg-core';
export const payroll = pgTable('payroll', {
id: serial('id').primaryKey(),
staffName: text('staff_name').notNull(),
title: text('title'),
level: text('level'),
basicSalary: numeric('basic_salary'),
housingAllowance: numeric('housing_allowance'),
transportAllowance: numeric('transport_allowance'),
utilityAllowance: numeric('utility_allowance'),
productivityAllowance: numeric('productivity_allowance'),
communicationAllowance: numeric('communication_allowance'),
inconvenienceAllowance: numeric('inconvenience_allowance'),
grossSalary: numeric('gross_salary'),
taxPaye: numeric('tax_paye'),
employeePension: numeric('employee_pension'),
totalDeduction: numeric('total_deduction'),
netSalary: numeric('net_salary'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Payroll = typeof payroll.$inferSelect;
export type NewPayroll = typeof payroll.$inferInsert;
import { pgTable, serial, text, numeric, timestamp } from 'drizzle-orm/pg-core';
export const tax = pgTable('tax', {
id: serial('id').primaryKey(),
taxType: text('tax_type').notNull(),
percentValue: numeric('percent_value'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Tax = typeof tax.$inferSelect;
export type NewTax = typeof tax.$inferInsert;
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const vehicle = pgTable('vehicle', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
type: text('type'),
licensePlate: text('license_plate').notNull().unique(),
driver: text('driver'),
status: text('status'),
lastMaintenance: timestamp('last_maintenance'),
nextMaintenance: timestamp('next_maintenance'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Vehicle = typeof vehicle.$inferSelect;
export type NewVehicle = typeof vehicle.$inferInsert;
export const delivery = pgTable('delivery', {
id: serial('id').primaryKey(),
item: text('item').notNull(),
origin: text('origin'),
destination: text('destination'),
vehicleId: integer('vehicle_id').references(() => vehicle.id),
driver: text('driver'),
departureDate: timestamp('departure_date'),
estimatedArrival: timestamp('estimated_arrival'),
status: text('status'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Delivery = typeof delivery.$inferSelect;
export type NewDelivery = typeof delivery.$inferInsert;
import { pgTable, serial, text, boolean, timestamp } from 'drizzle-orm/pg-core';
export const user = pgTable('user', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
password: text('password').notNull(),
role: text('role'),
twoFactorEnabled: boolean('two_factor_enabled').default(false),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type User = typeof user.$inferSelect;
export type NewUser = typeof user.$inferInsert;
import { pgTable, serial, text, integer, timestamp } from 'drizzle-orm/pg-core';
import { user } from './user';
export const session = pgTable('session', {
id: serial('id').primaryKey(),
userId: integer('user_id').references(() => user.id),
sessionToken: text('session_token').notNull().unique(),
expires: timestamp('expires').notNull(),
createdAt: timestamp('created_at').defaultNow(),
});
export type Session = typeof session.$inferSelect;
export type NewSession = typeof session.$inferInsert;
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const verificationToken = pgTable('verification_token', {
id: serial('id').primaryKey(),
identifier: text('identifier').notNull(),
token: text('token').notNull().unique(),
expires: timestamp('expires').notNull(),
createdAt: timestamp('created_at').defaultNow(),
});
export type VerificationToken = typeof verificationToken.$inferSelect;
export type NewVerificationToken = typeof verificationToken.$inferInsert;
import { pgTable, serial, text, integer, primaryKey } from 'drizzle-orm/pg-core';
import { user } from './user';
export const account = pgTable('account', {
id: serial('id').primaryKey(),
userId: integer('userId').notNull().references(() => user.id),
type: text('type').notNull(),
provider: text('provider').notNull(),
providerAccountId: text('providerAccountId').notNull(),
refreshToken: text('refresh_token'),
accessToken: text('access_token'),
expiresAt: integer('expires_at'),
tokenType: text('token_type'),
scope: text('scope'),
idToken: text('id_token'),
sessionState: text('session_state'),
});
export type Account = typeof account.$inferSelect;
export type NewAccount = typeof account.$inferInsert;
import { pgTable, serial, text, timestamp, integer } from 'drizzle-orm/pg-core';
export const training = pgTable('training', {
id: serial('id').primaryKey(),
description: text('description').notNull(),
startDate: timestamp('start_date'),
type: text('type'),
duration: text('duration'),
mode: text('mode'),
status: text('status'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type Training = typeof training.$inferSelect;
export type NewTraining = typeof training.$inferInsert;
export const trainingParticipants = pgTable('training_participants', {
id: serial('id').primaryKey(),
trainingId: integer('training_id').references(() => training.id),
staffId: integer('staff_id'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type TrainingParticipants = typeof trainingParticipants.$inferSelect;
export type NewTrainingParticipants = typeof trainingParticipants.$inferInsert;
import { pgTable, serial, text, integer, timestamp } from 'drizzle-orm/pg-core';
import { vehicle } from './logistics';
export const maintenanceSchedule = pgTable('maintenance_schedule', {
id: serial('id').primaryKey(),
vehicleId: integer('vehicle_id').references(() => vehicle.id),
scheduledDate: timestamp('scheduled_date'),
description: text('description'),
status: text('status'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type MaintenanceSchedule = typeof maintenanceSchedule.$inferSelect;
export type NewMaintenanceSchedule = typeof maintenanceSchedule.$inferInsert;
import { pgTable, serial, text, numeric, timestamp } from 'drizzle-orm/pg-core';
export const paymentVoucher = pgTable('payment_voucher', {
id: serial('id').primaryKey(),
date: timestamp('date'),
payee: text('payee'),
payeeAddress: text('payee_address'),
paymentMethod: text('payment_method'),
bankName: text('bank_name'),
accountNumber: text('account_number'),
accountName: text('account_name'),
amount: numeric('amount'),
description: text('description'),
category: text('category'),
requestedBy: text('requested_by'),
approvedBy: text('approved_by'),
status: text('status'),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export type PaymentVoucher = typeof paymentVoucher.$inferSelect;
export type NewPaymentVoucher = typeof paymentVoucher.$inferInsert;
import type { Config } from "drizzle-kit";
import { loadEnvConfig } from "@next/env";
loadEnvConfig("./");
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is missing");
}
export default {
schema: "./*.ts",
out: "./drizzle",
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL,
},
verbose: true,
strict: true,
} satisfies Config;
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { DATABASE_URL } from './config';
import * as schema from './schema';
const client = postgres(DATABASE_URL);
const db = drizzle(client, { schema });
export { db };
export * from "./staff";
export * from "./stock";
export * from "./memo";
export * from "./circular";
export * from "./procurement";
export * from "./inventory";
export * from "./office-budget";
export * from "./payroll";
export * from "./tax";
export * from "./logistics";
export * from "./user";
export * from "./session";
export * from "./verification-token";
export * from "./account";
export * from "./capacity-building";
export * from "./logistics-maintenance";