Files
relspecgo/tests/assets/drizzle/schema.ts
T
warkanum a32647ee16 fix: writer/reader correctness and determinism issues
- merge: cloneTable keeps relationships; skip-tables applies to new schemas
- diff: detect schema description/owner changes
- prisma: reader no longer turns relation fields into columns, enum
  detection via declared names; writer type mapping is ordered
- typeorm writer: keep explicit SQL types that cannot be inferred
- drizzle: enum columns call the enum constant; reader resolves them
- mysql/mssql/sqlite writers: honour OutputPath, deterministic column
  and constraint order; mssql live execute covers full schema
- template: ToYAML recovers from panics; Merge nil-pointer loop
- regenerate drizzle fixtures
2026-10-03 21:33:59 +02:00

85 lines
2.4 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;
role: Role;
}
export const user = pgTable('User', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
email: text('email').notNull().unique(),
name: text('name'),
role: role('role').notNull().default('USER'),
});
export type NewUser = typeof user.$inferInsert;
// Table: Profile
export interface Profile {
id: number;
bio: string;
userId: number;
}
export const profile = pgTable('Profile', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
bio: text('bio').notNull(),
userId: integer('userId').notNull().unique().references(() => user.id),
});
export type NewProfile = typeof profile.$inferInsert;
// Table: Post
export interface Post {
id: number;
authorId: number;
createdAt: Date;
published: boolean;
title: string;
updatedAt: Date; // @updatedAt
}
export const post = pgTable('Post', {
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
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;