Added Drizzle ORM support
This commit is contained in:
90
tests/assets/drizzle/schema.ts
Normal file
90
tests/assets/drizzle/schema.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
// 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;
|
||||
Reference in New Issue
Block a user