CREATE TYPE user_status as ENUM ('ACTIVE', 'INACTIVE');
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
status user_status NOT NULL
);
Run with --singular
pnpm kysely-codegen --singular
generates:
import type { ColumnType } from "kysely";
type UserStatus = 'ACTIVE' | 'INACTIVE'
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export interface User {
id: Generated<string>;
status: UserStatus;
}
export interface Database {
users: User;
}
Thank you for the fantastic tool!
As discussed on https://github.com/RobinBlomberg/kysely-codegen/issues/32, I've added option
--singular
.Examples
Given the schema:
Run with
--singular
generates:
NOTE: It does not touch enum names and values.