mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-31 08:21:45 +02:00
Add indexes on the niceId and orgId
This commit is contained in:
@@ -128,7 +128,8 @@ export const sites = pgTable(
|
|||||||
t.exitNodeId,
|
t.exitNodeId,
|
||||||
t.type,
|
t.type,
|
||||||
t.siteId
|
t.siteId
|
||||||
)
|
),
|
||||||
|
index("idx_sites_orgid_niceid").on(t.orgId, t.niceId)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -203,7 +204,9 @@ export const resources = pgTable(
|
|||||||
(t) => [
|
(t) => [
|
||||||
index("idx_resources_fulldomain")
|
index("idx_resources_fulldomain")
|
||||||
.on(t.fullDomain)
|
.on(t.fullDomain)
|
||||||
.where(sql`${t.fullDomain} IS NOT NULL`)
|
.where(sql`${t.fullDomain} IS NOT NULL`),
|
||||||
|
index("idx_resources_niceid").on(t.niceId),
|
||||||
|
index("idx_resources_orgid_niceid").on(t.orgId, t.niceId)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -384,63 +387,71 @@ export const exitNodes = pgTable("exitNodes", {
|
|||||||
region: varchar("region")
|
region: varchar("region")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const siteResources = pgTable("siteResources", {
|
export const siteResources = pgTable(
|
||||||
// this is for the clients
|
"siteResources",
|
||||||
siteResourceId: serial("siteResourceId").primaryKey(),
|
{
|
||||||
orgId: varchar("orgId")
|
// this is for the clients
|
||||||
.notNull()
|
siteResourceId: serial("siteResourceId").primaryKey(),
|
||||||
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
orgId: varchar("orgId")
|
||||||
networkId: integer("networkId").references(() => networks.networkId, {
|
.notNull()
|
||||||
onDelete: "set null"
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
}),
|
networkId: integer("networkId").references(() => networks.networkId, {
|
||||||
defaultNetworkId: integer("defaultNetworkId").references(
|
onDelete: "set null"
|
||||||
() => networks.networkId,
|
}),
|
||||||
{
|
defaultNetworkId: integer("defaultNetworkId").references(
|
||||||
onDelete: "restrict"
|
() => networks.networkId,
|
||||||
}
|
{
|
||||||
),
|
onDelete: "restrict"
|
||||||
niceId: varchar("niceId").notNull(),
|
}
|
||||||
name: varchar("name").notNull(),
|
),
|
||||||
ssl: boolean("ssl").notNull().default(false),
|
niceId: varchar("niceId").notNull(),
|
||||||
mode: varchar("mode").$type<"host" | "cidr" | "http" | "ssh">().notNull(), // "host" | "cidr" | "http"
|
name: varchar("name").notNull(),
|
||||||
scheme: varchar("scheme").$type<"http" | "https">(), // only for when we are doing https or http mode
|
ssl: boolean("ssl").notNull().default(false),
|
||||||
proxyPort: integer("proxyPort"), // only for port mode
|
mode: varchar("mode").$type<"host" | "cidr" | "http" | "ssh">().notNull(), // "host" | "cidr" | "http"
|
||||||
destinationPort: integer("destinationPort"), // only for port mode
|
scheme: varchar("scheme").$type<"http" | "https">(), // only for when we are doing https or http mode
|
||||||
destination: varchar("destination"), // ip, cidr, hostname; validate against the mode
|
proxyPort: integer("proxyPort"), // only for port mode
|
||||||
enabled: boolean("enabled").notNull().default(true),
|
destinationPort: integer("destinationPort"), // only for port mode
|
||||||
alias: varchar("alias"),
|
destination: varchar("destination"), // ip, cidr, hostname; validate against the mode
|
||||||
aliasAddress: varchar("aliasAddress"),
|
enabled: boolean("enabled").notNull().default(true),
|
||||||
tcpPortRangeString: varchar("tcpPortRangeString").notNull().default("*"),
|
alias: varchar("alias"),
|
||||||
udpPortRangeString: varchar("udpPortRangeString").notNull().default("*"),
|
aliasAddress: varchar("aliasAddress"),
|
||||||
disableIcmp: boolean("disableIcmp").notNull().default(false),
|
tcpPortRangeString: varchar("tcpPortRangeString").notNull().default("*"),
|
||||||
authDaemonPort: integer("authDaemonPort").default(22123),
|
udpPortRangeString: varchar("udpPortRangeString").notNull().default("*"),
|
||||||
pamMode: varchar("pamMode", { length: 32 })
|
disableIcmp: boolean("disableIcmp").notNull().default(false),
|
||||||
.$type<"passthrough" | "push">()
|
authDaemonPort: integer("authDaemonPort").default(22123),
|
||||||
.default("passthrough"),
|
pamMode: varchar("pamMode", { length: 32 })
|
||||||
authDaemonMode: varchar("authDaemonMode", { length: 32 })
|
.$type<"passthrough" | "push">()
|
||||||
.$type<"site" | "remote" | "native">()
|
.default("passthrough"),
|
||||||
.default("site"),
|
authDaemonMode: varchar("authDaemonMode", { length: 32 })
|
||||||
domainId: varchar("domainId").references(() => domains.domainId, {
|
.$type<"site" | "remote" | "native">()
|
||||||
onDelete: "set null"
|
.default("site"),
|
||||||
}),
|
domainId: varchar("domainId").references(() => domains.domainId, {
|
||||||
subdomain: varchar("subdomain"),
|
onDelete: "set null"
|
||||||
fullDomain: varchar("fullDomain")
|
}),
|
||||||
});
|
subdomain: varchar("subdomain"),
|
||||||
|
fullDomain: varchar("fullDomain")
|
||||||
|
},
|
||||||
|
(t) => [index("idx_siteresources_orgid_niceid").on(t.orgId, t.niceId)]
|
||||||
|
);
|
||||||
|
|
||||||
export const networks = pgTable("networks", {
|
export const networks = pgTable(
|
||||||
networkId: serial("networkId").primaryKey(),
|
"networks",
|
||||||
niceId: text("niceId"),
|
{
|
||||||
name: text("name"),
|
networkId: serial("networkId").primaryKey(),
|
||||||
scope: varchar("scope")
|
niceId: text("niceId"),
|
||||||
.$type<"global" | "resource">()
|
name: text("name"),
|
||||||
.notNull()
|
scope: varchar("scope")
|
||||||
.default("global"),
|
.$type<"global" | "resource">()
|
||||||
orgId: varchar("orgId")
|
.notNull()
|
||||||
.references(() => orgs.orgId, {
|
.default("global"),
|
||||||
onDelete: "cascade"
|
orgId: varchar("orgId")
|
||||||
})
|
.references(() => orgs.orgId, {
|
||||||
.notNull()
|
onDelete: "cascade"
|
||||||
});
|
})
|
||||||
|
.notNull()
|
||||||
|
},
|
||||||
|
(t) => [index("idx_networks_orgid").on(t.orgId)]
|
||||||
|
);
|
||||||
|
|
||||||
export const siteNetworks = pgTable(
|
export const siteNetworks = pgTable(
|
||||||
"siteNetworks",
|
"siteNetworks",
|
||||||
@@ -986,28 +997,32 @@ export const resourcePolicyRules = pgTable("resourcePolicyRules", {
|
|||||||
value: varchar("value").notNull()
|
value: varchar("value").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const resourcePolicies = pgTable("resourcePolicies", {
|
export const resourcePolicies = pgTable(
|
||||||
resourcePolicyId: serial("resourcePolicyId").primaryKey(),
|
"resourcePolicies",
|
||||||
sso: boolean("sso").notNull().default(true),
|
{
|
||||||
applyRules: boolean("applyRules").notNull().default(false),
|
resourcePolicyId: serial("resourcePolicyId").primaryKey(),
|
||||||
scope: varchar("scope")
|
sso: boolean("sso").notNull().default(true),
|
||||||
.$type<"global" | "resource">()
|
applyRules: boolean("applyRules").notNull().default(false),
|
||||||
.notNull()
|
scope: varchar("scope")
|
||||||
.default("global"),
|
.$type<"global" | "resource">()
|
||||||
emailWhitelistEnabled: boolean("emailWhitelistEnabled")
|
.notNull()
|
||||||
.notNull()
|
.default("global"),
|
||||||
.default(false),
|
emailWhitelistEnabled: boolean("emailWhitelistEnabled")
|
||||||
idpId: integer("idpId").references(() => idp.idpId, {
|
.notNull()
|
||||||
onDelete: "set null"
|
.default(false),
|
||||||
}),
|
idpId: integer("idpId").references(() => idp.idpId, {
|
||||||
niceId: text("niceId").notNull(),
|
onDelete: "set null"
|
||||||
name: varchar("name").notNull(),
|
}),
|
||||||
orgId: varchar("orgId")
|
niceId: text("niceId").notNull(),
|
||||||
.references(() => orgs.orgId, {
|
name: varchar("name").notNull(),
|
||||||
onDelete: "cascade"
|
orgId: varchar("orgId")
|
||||||
})
|
.references(() => orgs.orgId, {
|
||||||
.notNull()
|
onDelete: "cascade"
|
||||||
});
|
})
|
||||||
|
.notNull()
|
||||||
|
},
|
||||||
|
(t) => [index("idx_resourcepolicies_orgid_niceid").on(t.orgId, t.niceId)]
|
||||||
|
);
|
||||||
|
|
||||||
export const supporterKey = pgTable("supporterKey", {
|
export const supporterKey = pgTable("supporterKey", {
|
||||||
keyId: serial("keyId").primaryKey(),
|
keyId: serial("keyId").primaryKey(),
|
||||||
@@ -1131,7 +1146,10 @@ export const clients = pgTable(
|
|||||||
"pending" | "approved" | "denied"
|
"pending" | "approved" | "denied"
|
||||||
>()
|
>()
|
||||||
},
|
},
|
||||||
(t) => [index("idx_clients_userid").on(t.userId)]
|
(t) => [
|
||||||
|
index("idx_clients_userid").on(t.userId),
|
||||||
|
index("idx_clients_orgid_niceid").on(t.orgId, t.niceId)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const clientSitesAssociationsCache = pgTable(
|
export const clientSitesAssociationsCache = pgTable(
|
||||||
|
|||||||
Reference in New Issue
Block a user