Files
relspecgo/tests/assets/drizzle/schema.ts
Hein 35bc9dfb5c
Some checks failed
CI / Test (1.24) (push) Failing after -24m8s
CI / Test (1.25) (push) Failing after -23m54s
CI / Lint (push) Failing after -25m2s
CI / Build (push) Successful in -25m18s
Added Drizzle ORM support
2025-12-28 10:15:30 +02:00

91 lines
2.5 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 role = pgEnum('Role', ['USER', 'ADMIN']);
export type Role = 'USER' | 'ADMIN';
// Table: User
export interface User {
id: number;
email: string;
name: string | null;
profile: string | null;
role: Role;
}
export const user = pgTable('User', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
email: text('email').notNull().unique(),
name: text('name'),
profile: text('profile'),
role: pgEnum('Role')('role').notNull().default('USER'),
});
export type NewUser = typeof user.$inferInsert;
// Table: Profile
export interface Profile {
id: number;
bio: string;
user: string;
userId: number;
}
export const profile = pgTable('Profile', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
bio: text('bio').notNull(),
user: text('user').notNull(),
userId: integer('userId').notNull().unique().references(() => user.id),
});
export type NewProfile = typeof profile.$inferInsert;
// Table: Post
export interface Post {
id: number;
author: string;
authorId: number;
createdAt: Date;
published: boolean;
title: string;
updatedAt: Date; // @updatedAt
}
export const post = pgTable('Post', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
author: text('author').notNull(),
authorId: integer('authorId').notNull().references(() => user.id),
createdAt: timestamp('createdAt').notNull().default(sql`now()`),
published: boolean('published').notNull().default(false),
title: text('title').notNull(),
updatedAt: timestamp('updatedAt').notNull(), // @updatedAt
});
export type NewPost = typeof post.$inferInsert;
// Table: Category
export interface Category {
id: number;
name: string;
}
export const category = pgTable('Category', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
name: text('name').notNull(),
});
export type NewCategory = typeof category.$inferInsert;
// Table: _CategoryToPost
export interface Categorytopost {
categoryId: number;
postId: number;
}
export const Categorytopost = pgTable('_CategoryToPost', {
categoryId: integer('CategoryId').primaryKey().references(() => category.id),
postId: integer('PostId').primaryKey().references(() => post.id),
});
export type NewCategorytopost = typeof Categorytopost.$inferInsert;