mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-20 09:36:40 +00:00
Switch to using networks
This commit is contained in:
@@ -81,6 +81,10 @@ export const sites = pgTable("sites", {
|
|||||||
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
||||||
onDelete: "set null"
|
onDelete: "set null"
|
||||||
}),
|
}),
|
||||||
|
networkId: integer("networkId").references(
|
||||||
|
() => networks.networkId,
|
||||||
|
{ onDelete: "set null" }
|
||||||
|
),
|
||||||
name: varchar("name").notNull(),
|
name: varchar("name").notNull(),
|
||||||
pubKey: varchar("pubKey"),
|
pubKey: varchar("pubKey"),
|
||||||
subnet: varchar("subnet"),
|
subnet: varchar("subnet"),
|
||||||
@@ -219,6 +223,16 @@ export const siteResources = pgTable("siteResources", {
|
|||||||
orgId: varchar("orgId")
|
orgId: varchar("orgId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
|
networkId: integer("networkId").references(
|
||||||
|
() => networks.networkId,
|
||||||
|
{ onDelete: "set null" }
|
||||||
|
),
|
||||||
|
defaultNetworkId: integer("defaultNetworkId").references(
|
||||||
|
() => networks.networkId,
|
||||||
|
{
|
||||||
|
onDelete: "restrict"
|
||||||
|
}
|
||||||
|
),
|
||||||
niceId: varchar("niceId").notNull(),
|
niceId: varchar("niceId").notNull(),
|
||||||
name: varchar("name").notNull(),
|
name: varchar("name").notNull(),
|
||||||
mode: varchar("mode").$type<"host" | "cidr">().notNull(), // "host" | "cidr" | "port"
|
mode: varchar("mode").$type<"host" | "cidr">().notNull(), // "host" | "cidr" | "port"
|
||||||
@@ -238,13 +252,19 @@ export const siteResources = pgTable("siteResources", {
|
|||||||
.default("site")
|
.default("site")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const siteSiteResources = pgTable("siteSiteResources", {
|
export const networks = pgTable("networks", {
|
||||||
siteId: integer("siteId")
|
networkId: serial("networkId").primaryKey(),
|
||||||
|
niceId: text("niceId").notNull(),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
scope: varchar("scope")
|
||||||
|
.$type<"global" | "resource">()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => sites.siteId, { onDelete: "cascade" }),
|
.default("global"),
|
||||||
siteResourceId: integer("siteResourceId")
|
orgId: varchar("orgId")
|
||||||
|
.references(() => orgs.orgId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
})
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => siteResources.siteResourceId, { onDelete: "cascade" })
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const clientSiteResources = pgTable("clientSiteResources", {
|
export const clientSiteResources = pgTable("clientSiteResources", {
|
||||||
@@ -1080,3 +1100,4 @@ export type RequestAuditLog = InferSelectModel<typeof requestAuditLog>;
|
|||||||
export type RoundTripMessageTracker = InferSelectModel<
|
export type RoundTripMessageTracker = InferSelectModel<
|
||||||
typeof roundTripMessageTracker
|
typeof roundTripMessageTracker
|
||||||
>;
|
>;
|
||||||
|
export type Network = InferSelectModel<typeof networks>;
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ export const sites = sqliteTable("sites", {
|
|||||||
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
||||||
onDelete: "set null"
|
onDelete: "set null"
|
||||||
}),
|
}),
|
||||||
|
networkId: integer("networkId").references(() => networks.networkId, {
|
||||||
|
onDelete: "set null"
|
||||||
|
}),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
pubKey: text("pubKey"),
|
pubKey: text("pubKey"),
|
||||||
subnet: text("subnet"),
|
subnet: text("subnet"),
|
||||||
@@ -242,6 +245,13 @@ export const siteResources = sqliteTable("siteResources", {
|
|||||||
orgId: text("orgId")
|
orgId: text("orgId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
|
networkId: integer("networkId").references(() => networks.networkId, {
|
||||||
|
onDelete: "set null"
|
||||||
|
}),
|
||||||
|
defaultNetworkId: integer("defaultNetworkId").references(
|
||||||
|
() => networks.networkId,
|
||||||
|
{ onDelete: "restrict" }
|
||||||
|
),
|
||||||
niceId: text("niceId").notNull(),
|
niceId: text("niceId").notNull(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
mode: text("mode").$type<"host" | "cidr">().notNull(), // "host" | "cidr" | "port"
|
mode: text("mode").$type<"host" | "cidr">().notNull(), // "host" | "cidr" | "port"
|
||||||
@@ -263,13 +273,17 @@ export const siteResources = sqliteTable("siteResources", {
|
|||||||
.default("site")
|
.default("site")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const siteSiteResources = sqliteTable("siteSiteResources", {
|
export const networks = sqliteTable("networks", {
|
||||||
siteId: integer("siteId")
|
networkId: integer("networkId").primaryKey({ autoIncrement: true }),
|
||||||
|
niceId: text("niceId").notNull(),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
scope: text("scope")
|
||||||
|
.$type<"global" | "resource">()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => sites.siteId, { onDelete: "cascade" }),
|
.default("global"),
|
||||||
siteResourceId: integer("siteResourceId")
|
orgId: text("orgId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => siteResources.siteResourceId, { onDelete: "cascade" })
|
.references(() => orgs.orgId, { onDelete: "cascade" })
|
||||||
});
|
});
|
||||||
|
|
||||||
export const clientSiteResources = sqliteTable("clientSiteResources", {
|
export const clientSiteResources = sqliteTable("clientSiteResources", {
|
||||||
@@ -1164,6 +1178,7 @@ export type ApiKey = InferSelectModel<typeof apiKeys>;
|
|||||||
export type ApiKeyAction = InferSelectModel<typeof apiKeyActions>;
|
export type ApiKeyAction = InferSelectModel<typeof apiKeyActions>;
|
||||||
export type ApiKeyOrg = InferSelectModel<typeof apiKeyOrg>;
|
export type ApiKeyOrg = InferSelectModel<typeof apiKeyOrg>;
|
||||||
export type SiteResource = InferSelectModel<typeof siteResources>;
|
export type SiteResource = InferSelectModel<typeof siteResources>;
|
||||||
|
export type Network = InferSelectModel<typeof networks>;
|
||||||
export type OrgDomains = InferSelectModel<typeof orgDomains>;
|
export type OrgDomains = InferSelectModel<typeof orgDomains>;
|
||||||
export type SetupToken = InferSelectModel<typeof setupTokens>;
|
export type SetupToken = InferSelectModel<typeof setupTokens>;
|
||||||
export type HostMeta = InferSelectModel<typeof hostMeta>;
|
export type HostMeta = InferSelectModel<typeof hostMeta>;
|
||||||
|
|||||||
Reference in New Issue
Block a user