mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-05 14:05:30 +02:00
refactor: simplify naming schema
This commit is contained in:
@@ -21,11 +21,7 @@ import { security } from "./security";
|
||||
import { applicationStatus } from "./shared";
|
||||
import { sshKeys } from "./ssh-key";
|
||||
import { generateAppName } from "./utils";
|
||||
import {
|
||||
bitbucketProvider,
|
||||
githubProvider,
|
||||
gitlabProvider,
|
||||
} from "./git-provider";
|
||||
import { bitbucket, github, gitlab } from "./git-provider";
|
||||
|
||||
export const sourceType = pgEnum("sourceType", [
|
||||
"docker",
|
||||
@@ -187,18 +183,15 @@ export const applications = pgTable("application", {
|
||||
projectId: text("projectId")
|
||||
.notNull()
|
||||
.references(() => projects.projectId, { onDelete: "cascade" }),
|
||||
githubId: text("githubId").references(() => githubProvider.githubId, {
|
||||
githubId: text("githubId").references(() => github.githubId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
gitlabId: text("gitlabId").references(() => gitlabProvider.gitlabId, {
|
||||
gitlabId: text("gitlabId").references(() => gitlab.gitlabId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(() => bitbucket.bitbucketId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(
|
||||
() => bitbucketProvider.bitbucketId,
|
||||
{
|
||||
onDelete: "set null",
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
export const applicationsRelations = relations(
|
||||
@@ -222,17 +215,17 @@ export const applicationsRelations = relations(
|
||||
fields: [applications.registryId],
|
||||
references: [registry.registryId],
|
||||
}),
|
||||
githubProvider: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [applications.githubId],
|
||||
references: [githubProvider.githubId],
|
||||
references: [github.githubId],
|
||||
}),
|
||||
gitlabProvider: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [applications.gitlabId],
|
||||
references: [gitlabProvider.gitlabId],
|
||||
references: [gitlab.gitlabId],
|
||||
}),
|
||||
bitbucketProvider: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [applications.bitbucketId],
|
||||
references: [bitbucketProvider.bitbucketId],
|
||||
references: [bitbucket.bitbucketId],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -10,11 +10,7 @@ import { mounts } from "./mount";
|
||||
import { projects } from "./project";
|
||||
import { applicationStatus } from "./shared";
|
||||
import { generateAppName } from "./utils";
|
||||
import {
|
||||
bitbucketProvider,
|
||||
githubProvider,
|
||||
gitlabProvider,
|
||||
} from "./git-provider";
|
||||
import { bitbucket, github, gitlab } from "./git-provider";
|
||||
|
||||
export const sourceTypeCompose = pgEnum("sourceTypeCompose", [
|
||||
"git",
|
||||
@@ -76,18 +72,15 @@ export const compose = pgTable("compose", {
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
|
||||
githubId: text("githubId").references(() => githubProvider.githubId, {
|
||||
githubId: text("githubId").references(() => github.githubId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
gitlabId: text("gitlabId").references(() => gitlabProvider.gitlabId, {
|
||||
gitlabId: text("gitlabId").references(() => gitlab.gitlabId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(() => bitbucket.bitbucketId, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
bitbucketId: text("bitbucketId").references(
|
||||
() => bitbucketProvider.bitbucketId,
|
||||
{
|
||||
onDelete: "set null",
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
export const composeRelations = relations(compose, ({ one, many }) => ({
|
||||
@@ -102,17 +95,17 @@ export const composeRelations = relations(compose, ({ one, many }) => ({
|
||||
references: [sshKeys.sshKeyId],
|
||||
}),
|
||||
domains: many(domains),
|
||||
githubProvider: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [compose.githubId],
|
||||
references: [githubProvider.githubId],
|
||||
references: [github.githubId],
|
||||
}),
|
||||
gitlabProvider: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [compose.gitlabId],
|
||||
references: [gitlabProvider.gitlabId],
|
||||
references: [gitlab.gitlabId],
|
||||
}),
|
||||
bitbucketProvider: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [compose.bitbucketId],
|
||||
references: [bitbucketProvider.bitbucketId],
|
||||
references: [bitbucket.bitbucketId],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
@@ -27,17 +27,17 @@ export const gitProvider = pgTable("git_provider", {
|
||||
});
|
||||
|
||||
export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
github: one(githubProvider, {
|
||||
github: one(github, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [githubProvider.gitProviderId],
|
||||
references: [github.gitProviderId],
|
||||
}),
|
||||
gitlab: one(gitlabProvider, {
|
||||
gitlab: one(gitlab, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [gitlabProvider.gitProviderId],
|
||||
references: [gitlab.gitProviderId],
|
||||
}),
|
||||
bitbucket: one(bitbucketProvider, {
|
||||
bitbucket: one(bitbucket, {
|
||||
fields: [gitProvider.gitProviderId],
|
||||
references: [bitbucketProvider.gitProviderId],
|
||||
references: [bitbucket.gitProviderId],
|
||||
}),
|
||||
auth: one(auth, {
|
||||
fields: [gitProvider.authId],
|
||||
@@ -45,7 +45,7 @@ export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const githubProvider = pgTable("github_provider", {
|
||||
export const github = pgTable("github", {
|
||||
githubId: text("githubId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@@ -62,17 +62,14 @@ export const githubProvider = pgTable("github_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const githubProviderRelations = relations(
|
||||
githubProvider,
|
||||
({ one, }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [githubProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const githubProviderRelations = relations(github, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [github.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export const gitlabProvider = pgTable("gitlab_provider", {
|
||||
export const gitlab = pgTable("gitlab", {
|
||||
gitlabId: text("gitlabId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@@ -89,17 +86,14 @@ export const gitlabProvider = pgTable("gitlab_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const gitlabProviderRelations = relations(
|
||||
gitlabProvider,
|
||||
({ one}) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [gitlabProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const gitlabProviderRelations = relations(gitlab, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [gitlab.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export const bitbucketProvider = pgTable("bitbucket_provider", {
|
||||
export const bitbucket = pgTable("bitbucket", {
|
||||
bitbucketId: text("bitbucketId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
@@ -112,19 +106,16 @@ export const bitbucketProvider = pgTable("bitbucket_provider", {
|
||||
.references(() => gitProvider.gitProviderId, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const bitbucketProviderRelations = relations(
|
||||
bitbucketProvider,
|
||||
({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [bitbucketProvider.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
export const bitbucketProviderRelations = relations(bitbucket, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [bitbucket.gitProviderId],
|
||||
references: [gitProvider.gitProviderId],
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(gitProvider);
|
||||
|
||||
export const apiCreateGithubProvider = createSchema.extend({
|
||||
export const apiCreateGithub = createSchema.extend({
|
||||
githubAppName: z.string().optional(),
|
||||
githubAppId: z.number().optional(),
|
||||
githubClientId: z.string().optional(),
|
||||
@@ -135,7 +126,7 @@ export const apiCreateGithubProvider = createSchema.extend({
|
||||
gitProviderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const apiCreateGitlabProvider = createSchema.extend({
|
||||
export const apiCreateGitlab = createSchema.extend({
|
||||
applicationId: z.string().optional(),
|
||||
secret: z.string().optional(),
|
||||
groupName: z.string().optional(),
|
||||
@@ -143,7 +134,7 @@ export const apiCreateGitlabProvider = createSchema.extend({
|
||||
redirectUri: z.string().optional(),
|
||||
});
|
||||
|
||||
export const apiCreateBitbucketProvider = createSchema.extend({
|
||||
export const apiCreateBitbucket = createSchema.extend({
|
||||
bitbucketUsername: z.string().optional(),
|
||||
appPassword: z.string().optional(),
|
||||
bitbucketWorkspaceName: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user