Add indexes on the niceId and orgId

This commit is contained in:
Owen
2026-06-30 09:41:32 -04:00
parent b41c1f5b27
commit 29563a13a4
+27 -9
View File
@@ -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,7 +387,9 @@ export const exitNodes = pgTable("exitNodes", {
region: varchar("region") region: varchar("region")
}); });
export const siteResources = pgTable("siteResources", { export const siteResources = pgTable(
"siteResources",
{
// this is for the clients // this is for the clients
siteResourceId: serial("siteResourceId").primaryKey(), siteResourceId: serial("siteResourceId").primaryKey(),
orgId: varchar("orgId") orgId: varchar("orgId")
@@ -425,9 +430,13 @@ export const siteResources = pgTable("siteResources", {
}), }),
subdomain: varchar("subdomain"), subdomain: varchar("subdomain"),
fullDomain: varchar("fullDomain") fullDomain: varchar("fullDomain")
}); },
(t) => [index("idx_siteresources_orgid_niceid").on(t.orgId, t.niceId)]
);
export const networks = pgTable("networks", { export const networks = pgTable(
"networks",
{
networkId: serial("networkId").primaryKey(), networkId: serial("networkId").primaryKey(),
niceId: text("niceId"), niceId: text("niceId"),
name: text("name"), name: text("name"),
@@ -440,7 +449,9 @@ export const networks = pgTable("networks", {
onDelete: "cascade" onDelete: "cascade"
}) })
.notNull() .notNull()
}); },
(t) => [index("idx_networks_orgid").on(t.orgId)]
);
export const siteNetworks = pgTable( export const siteNetworks = pgTable(
"siteNetworks", "siteNetworks",
@@ -986,7 +997,9 @@ export const resourcePolicyRules = pgTable("resourcePolicyRules", {
value: varchar("value").notNull() value: varchar("value").notNull()
}); });
export const resourcePolicies = pgTable("resourcePolicies", { export const resourcePolicies = pgTable(
"resourcePolicies",
{
resourcePolicyId: serial("resourcePolicyId").primaryKey(), resourcePolicyId: serial("resourcePolicyId").primaryKey(),
sso: boolean("sso").notNull().default(true), sso: boolean("sso").notNull().default(true),
applyRules: boolean("applyRules").notNull().default(false), applyRules: boolean("applyRules").notNull().default(false),
@@ -1007,7 +1020,9 @@ export const resourcePolicies = pgTable("resourcePolicies", {
onDelete: "cascade" onDelete: "cascade"
}) })
.notNull() .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(