157 lines
6.3 KiB
TypeScript
157 lines
6.3 KiB
TypeScript
// Code generated by relspecgo. DO NOT EDIT.
|
|
import { pgTable, pgEnum, integer, bigint, smallint, serial, bigserial, smallserial, text, varchar, char, boolean, numeric, real, doublePrecision, timestamp, date, time, interval, json, jsonb, uuid, bytea } from 'drizzle-orm/pg-core';
|
|
import { sql } from 'drizzle-orm';
|
|
|
|
|
|
// Enums
|
|
export const userRole = pgEnum('UserRole', ['admin', 'user', 'moderator', 'guest']);
|
|
export const orderStatus = pgEnum('OrderStatus', ['pending', 'processing', 'shipped', 'delivered', 'cancelled']);
|
|
|
|
|
|
// Table: users
|
|
export const users = pgTable('users', {
|
|
id: serial('id').primaryKey(),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
email: varchar('email').notNull().unique(),
|
|
isActive: boolean('is_active').notNull().default(true),
|
|
lastLoginAt: timestamp('last_login_at'),
|
|
passwordHash: varchar('password_hash').notNull(),
|
|
profile: jsonb('profile'),
|
|
role: pgEnum('UserRole')('role').notNull(),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
username: varchar('username').notNull().unique(),
|
|
});
|
|
|
|
// Types for users
|
|
export type Users = typeof users.$inferSelect;
|
|
export type NewUsers = typeof users.$inferInsert;
|
|
// Table: profiles
|
|
export const profiles = pgTable('profiles', {
|
|
id: serial('id').primaryKey(),
|
|
avatarUrl: varchar('avatar_url'),
|
|
bio: text('bio'),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
dateOfBirth: date('date_of_birth'),
|
|
firstName: varchar('first_name'),
|
|
lastName: varchar('last_name'),
|
|
phoneNumber: varchar('phone_number'),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
userId: integer('user_id').notNull().unique().references(() => users.id),
|
|
});
|
|
|
|
// Types for profiles
|
|
export type Profiles = typeof profiles.$inferSelect;
|
|
export type NewProfiles = typeof profiles.$inferInsert;
|
|
// Table: posts
|
|
export const posts = pgTable('posts', {
|
|
id: serial('id').primaryKey(),
|
|
authorId: integer('author_id').notNull().references(() => users.id),
|
|
content: text('content').notNull(),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
excerpt: text('excerpt'),
|
|
featuredImage: varchar('featured_image'),
|
|
isPublished: boolean('is_published').notNull().default(false),
|
|
publishedAt: timestamp('published_at'),
|
|
slug: varchar('slug').notNull().unique(),
|
|
title: varchar('title').notNull(),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
viewCount: integer('view_count').notNull().default(0),
|
|
});
|
|
|
|
// Types for posts
|
|
export type Posts = typeof posts.$inferSelect;
|
|
export type NewPosts = typeof posts.$inferInsert;
|
|
// Table: comments
|
|
export const comments = pgTable('comments', {
|
|
id: serial('id').primaryKey(),
|
|
authorId: integer('author_id').notNull().references(() => users.id),
|
|
content: text('content').notNull(),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
isApproved: boolean('is_approved').notNull().default(false),
|
|
parentId: integer('parent_id').references(() => comments.id),
|
|
postId: integer('post_id').notNull().references(() => posts.id),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
});
|
|
|
|
// Types for comments
|
|
export type Comments = typeof comments.$inferSelect;
|
|
export type NewComments = typeof comments.$inferInsert;
|
|
// Table: categories
|
|
export const categories = pgTable('categories', {
|
|
id: serial('id').primaryKey(),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
description: text('description'),
|
|
name: varchar('name').notNull().unique(),
|
|
parentId: integer('parent_id').references(() => categories.id),
|
|
slug: varchar('slug').notNull().unique(),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
});
|
|
|
|
// Types for categories
|
|
export type Categories = typeof categories.$inferSelect;
|
|
export type NewCategories = typeof categories.$inferInsert;
|
|
// Table: post_categories
|
|
export const postCategories = pgTable('post_categories', {
|
|
categoryId: integer('category_id').notNull().references(() => categories.id),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
postId: integer('post_id').notNull().references(() => posts.id),
|
|
});
|
|
|
|
// Types for post_categories
|
|
export type PostCategories = typeof postCategories.$inferSelect;
|
|
export type NewPostCategories = typeof postCategories.$inferInsert;
|
|
// Table: tags
|
|
export const tags = pgTable('tags', {
|
|
id: serial('id').primaryKey(),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
name: varchar('name').notNull().unique(),
|
|
slug: varchar('slug').notNull().unique(),
|
|
});
|
|
|
|
// Types for tags
|
|
export type Tags = typeof tags.$inferSelect;
|
|
export type NewTags = typeof tags.$inferInsert;
|
|
// Table: post_tags
|
|
export const postTags = pgTable('post_tags', {
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
postId: integer('post_id').notNull().references(() => posts.id),
|
|
tagId: integer('tag_id').notNull().references(() => tags.id),
|
|
});
|
|
|
|
// Types for post_tags
|
|
export type PostTags = typeof postTags.$inferSelect;
|
|
export type NewPostTags = typeof postTags.$inferInsert;
|
|
// Table: orders
|
|
export const orders = pgTable('orders', {
|
|
id: serial('id').primaryKey(),
|
|
billingAddress: jsonb('billing_address').notNull(),
|
|
completedAt: timestamp('completed_at'),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
currency: varchar('currency').notNull().default('USD'),
|
|
notes: text('notes'),
|
|
orderNumber: varchar('order_number').notNull().unique(),
|
|
shippingAddress: jsonb('shipping_address').notNull(),
|
|
status: pgEnum('OrderStatus')('status').notNull().default('pending'),
|
|
totalAmount: numeric('total_amount').notNull(),
|
|
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
|
userId: integer('user_id').notNull().references(() => users.id),
|
|
});
|
|
|
|
// Types for orders
|
|
export type Orders = typeof orders.$inferSelect;
|
|
export type NewOrders = typeof orders.$inferInsert;
|
|
// Table: sessions
|
|
export const sessions = pgTable('sessions', {
|
|
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
|
|
createdAt: timestamp('created_at').notNull().default(sql`now()`),
|
|
expiresAt: timestamp('expires_at').notNull(),
|
|
ipAddress: varchar('ip_address'),
|
|
token: varchar('token').notNull().unique(),
|
|
userAgent: text('user_agent'),
|
|
userId: integer('user_id').notNull().references(() => users.id),
|
|
});
|
|
|
|
// Types for sessions
|
|
export type Sessions = typeof sessions.$inferSelect;
|
|
export type NewSessions = typeof sessions.$inferInsert;
|