2024-05-08 00:19:13 +00:00
|
|
|
import { pgEnum, pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
|
|
|
|
import { createId as cuid2 } from '@paralleldrive/cuid2';
|
|
|
|
|
import type { InferSelectModel } from 'drizzle-orm';
|
|
|
|
|
|
2024-06-15 02:11:18 +00:00
|
|
|
export const externalIdType = pgEnum('external_id_type', [
|
2024-05-08 00:19:13 +00:00
|
|
|
'game',
|
|
|
|
|
'category',
|
|
|
|
|
'mechanic',
|
|
|
|
|
'publisher',
|
|
|
|
|
'designer',
|
|
|
|
|
'artist',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const externalIds = pgTable('external_ids', {
|
|
|
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
|
|
|
cuid: text('cuid')
|
|
|
|
|
.unique()
|
|
|
|
|
.$defaultFn(() => cuid2()),
|
2024-06-15 02:11:18 +00:00
|
|
|
type: externalIdType('type'),
|
2024-05-08 00:19:13 +00:00
|
|
|
externalId: text('external_id').notNull(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type ExternalIds = InferSelectModel<typeof externalIds>;
|
|
|
|
|
|
|
|
|
|
export default externalIds;
|