Files
twenty/packages/twenty-website/src/database/model.ts
Ady Beraud 0a7f82333b Make Github stars dynamic and improve database init (#5000)
I extracted the init database logic into its own file. 
You can now run it with yarn database:init.
Added database entry for GitHub stars. 

Do you want me to remove the init route or is it used for something else
?

---------

Co-authored-by: Ady Beraud <a.beraud96@gmail.com>
Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-04-24 09:44:44 +02:00

51 lines
1.7 KiB
TypeScript

import {
pgGithubStars,
pgIssueLabels,
pgIssues,
pgLabels,
pgPullRequestLabels,
pgPullRequests,
pgUsers,
} from '@/database/postgres/schema-postgres';
import {
sqlLiteIssueLabels,
sqlLiteIssues,
sqlLiteLabels,
sqlLitePullRequestLabels,
sqlLitePullRequests,
sqlLiteUsers,
} from '@/database/sqlite/schema-sqlite';
const databaseDriver = global.process.env.DATABASE_DRIVER;
const isSqliteDriver = databaseDriver === 'sqlite';
export const userModel = isSqliteDriver ? sqlLiteUsers : pgUsers;
export const pullRequestModel = isSqliteDriver
? sqlLitePullRequests
: pgPullRequests;
export const issueModel = isSqliteDriver ? sqlLiteIssues : pgIssues;
export const labelModel = isSqliteDriver ? sqlLiteLabels : pgLabels;
export const pullRequestLabelModel = isSqliteDriver
? sqlLitePullRequestLabels
: pgPullRequestLabels;
export const issueLabelModel = isSqliteDriver
? sqlLiteIssueLabels
: pgIssueLabels;
export const githubStarsModel = pgGithubStars;
export type User = typeof pgUsers.$inferSelect;
export type PullRequest = typeof pgPullRequests.$inferSelect;
export type Issue = typeof pgIssues.$inferSelect;
export type Label = typeof pgLabels.$inferSelect;
export type PullRequestLabel = typeof pgPullRequestLabels.$inferSelect;
export type IssueLabel = typeof pgIssueLabels.$inferSelect;
export type UserInsert = typeof pgUsers.$inferInsert;
export type PullRequestInsert = typeof pgPullRequests.$inferInsert;
export type IssueInsert = typeof pgIssues.$inferInsert;
export type LabelInsert = typeof pgLabels.$inferInsert;
export type PullRequestLabelInsert = typeof pgPullRequestLabels.$inferInsert;
export type IssueLabelInsert = typeof pgIssueLabels.$inferInsert;
export type GithubStars = typeof pgGithubStars.$inferInsert;