Files
twenty_crm/packages/twenty-website/src/database/postgres/schema-postgres.ts
Charles Bochet 4613f64910 Add proper ORM and postgres support (#3978)
* Add postgresql support

* Fixes

* Fix perfs
2024-02-14 17:53:50 +01:00

53 lines
1.4 KiB
TypeScript

import { pgTable, text } from 'drizzle-orm/pg-core';
export const pgUsers = pgTable('users', {
id: text('id').primaryKey(),
avatarUrl: text('avatarUrl'),
url: text('url'),
isEmployee: text('isEmployee'),
});
export const pgPullRequests = pgTable('pullRequests', {
id: text('id').primaryKey(),
name: text('title'),
body: text('body'),
url: text('url'),
createdAt: text('createdAt'),
updatedAt: text('updatedAt'),
closedAt: text('closedAt'),
mergedAt: text('mergedAt'),
authorId: text('authorId').references(() => pgUsers.id),
});
export const pgIssues = pgTable('issues', {
id: text('id').primaryKey(),
externalId: text('externalId'),
title: text('title'),
body: text('body'),
url: text('url'),
createdAt: text('createdAt'),
updatedAt: text('updatedAt'),
closedAt: text('closedAt'),
authorId: text('authorId').references(() => pgUsers.id),
});
export const pgLabels = pgTable('labels', {
id: text('id').primaryKey(),
externalId: text('externalId'),
name: text('name'),
color: text('color'),
description: text('description'),
});
export const pgPullRequestLabels = pgTable('pullRequestLabels', {
pullRequestId: text('pullRequestExternalId').references(
() => pgPullRequests.id,
),
labelId: text('labelId').references(() => pgLabels.id),
});
export const pgIssueLabels = pgTable('issueLabels', {
issueId: text('issueId').references(() => pgIssues.id),
labelId: text('labelId').references(() => pgLabels.id),
});