mic-bot/repo/scheme.ts

40 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2024-10-19 10:00:35 +00:00
import { ColumnType, Insertable, Selectable, Updateable } from "npm:kysely";
2024-10-23 16:09:10 +00:00
// Shortcuts cuz my monitor is small ;(
type Nothing = undefined | null
2024-10-19 10:00:35 +00:00
type DateOrStr = Date | string
type WrittableOnce<type> = ColumnType<type, type, never>
2024-10-23 16:09:10 +00:00
type WithDefault<type> = ColumnType<type, type | Nothing, type>
2024-10-19 10:00:35 +00:00
2024-10-23 16:09:10 +00:00
export interface TableUsers {
id: ColumnType<string, string | Nothing, never>
tg_id: number | null
joined_by_referal_from_user_id: WrittableOnce<string | null>
is_chat_participant: WithDefault<boolean>
is_captcha_passed: WithDefault<boolean>
is_timeout: WithDefault<boolean>
is_banned: WithDefault<boolean>
created_at: ColumnType<Date, DateOrStr | Nothing, never>
joined_chat_at: ColumnType<Date | null, DateOrStr | Nothing, DateOrStr>
timeout_until: ColumnType<Date | null, DateOrStr | Nothing, DateOrStr | null>
2024-10-19 10:00:35 +00:00
}
export interface TableInviteLinks {
link: WrittableOnce<string>
expect_user_tg_id: WrittableOnce<number>
2024-10-23 16:09:10 +00:00
valid_until: ColumnType<Date | null, DateOrStr | Nothing, never>
2024-10-19 10:00:35 +00:00
}
export interface Database {
2024-10-23 16:09:10 +00:00
users: TableUsers
invite_links: TableInviteLinks
2024-10-19 10:00:35 +00:00
}
export type SelectUser = Selectable<TableUsers>
export type InsertUser = Insertable<TableUsers>
export type UpdateUser = Updateable<TableUsers>
export type SelectInviteLinks = Selectable<TableInviteLinks>
export type InsertInviteLinks = Insertable<TableInviteLinks>
export type UpdateInviteLinks = Updateable<TableInviteLinks>