fosrl.pangolin/server/migrations/0000_short_ulik.sql

58 lines
1.8 KiB
MySQL
Raw Normal View History

2024-09-28 11:52:51 -04:00
CREATE TABLE `exitNodes` (
`exitNodeId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
2024-09-28 13:31:22 -04:00
`name` text NOT NULL,
`address` text NOT NULL
2024-09-28 11:52:51 -04:00
);
--> statement-breakpoint
2024-09-28 13:31:22 -04:00
CREATE TABLE `orgs` (
2024-09-28 11:52:51 -04:00
`orgId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
2024-09-28 13:31:22 -04:00
`name` text NOT NULL,
`domain` text NOT NULL
2024-09-28 11:52:51 -04:00
);
--> statement-breakpoint
CREATE TABLE `resources` (
`resourceId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`siteId` integer,
2024-09-28 13:31:22 -04:00
`name` text NOT NULL,
`subdomain` text,
2024-09-28 11:52:51 -04:00
FOREIGN KEY (`siteId`) REFERENCES `sites`(`siteId`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `routes` (
`routeId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`exitNodeId` integer,
2024-09-28 13:31:22 -04:00
`subnet` text NOT NULL,
2024-09-28 11:52:51 -04:00
FOREIGN KEY (`exitNodeId`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `sites` (
`siteId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`orgId` integer,
`exitNode` integer,
2024-09-28 13:31:22 -04:00
`name` text NOT NULL,
`subdomain` text,
`pubKey` text,
`subnet` text,
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE no action,
2024-09-28 11:52:51 -04:00
FOREIGN KEY (`exitNode`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
2024-09-28 13:31:22 -04:00
CREATE TABLE `targets` (
`targetId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`resourceId` integer,
`ip` text NOT NULL,
`method` text,
`port` integer,
`protocol` text,
FOREIGN KEY (`resourceId`) REFERENCES `resources`(`resourceId`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
2024-09-28 11:52:51 -04:00
CREATE TABLE `users` (
2024-09-28 13:31:22 -04:00
`userId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
2024-09-28 11:52:51 -04:00
`orgId` integer,
2024-09-28 13:31:22 -04:00
`name` text NOT NULL,
`email` text NOT NULL,
2024-09-28 11:52:51 -04:00
`groups` text,
2024-09-28 13:31:22 -04:00
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE no action
2024-09-28 11:52:51 -04:00
);