Adjust schema

This commit is contained in:
Owen Schwartz
2024-09-28 17:10:03 -04:00
parent 7bb81af3bb
commit 2970088b29
6 changed files with 123 additions and 104 deletions

View File

@@ -13,18 +13,18 @@ CREATE TABLE `orgs` (
);
--> statement-breakpoint
CREATE TABLE `resources` (
`resourceId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`resourceId` text(2048) PRIMARY KEY NOT NULL,
`siteId` integer,
`name` text NOT NULL,
`subdomain` text,
FOREIGN KEY (`siteId`) REFERENCES `sites`(`siteId`) ON UPDATE no action ON DELETE no action
FOREIGN KEY (`siteId`) REFERENCES `sites`(`siteId`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `routes` (
`routeId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`exitNodeId` integer,
`subnet` text NOT NULL,
FOREIGN KEY (`exitNodeId`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE no action
FOREIGN KEY (`exitNodeId`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `sites` (
@@ -35,18 +35,18 @@ CREATE TABLE `sites` (
`subdomain` text,
`pubKey` text,
`subnet` text,
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`exitNode`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE no action
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`exitNode`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `targets` (
`targetId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`resourceId` integer,
`resourceId` text,
`ip` text NOT NULL,
`method` text,
`port` integer,
`protocol` text,
FOREIGN KEY (`resourceId`) REFERENCES `resources`(`resourceId`) ON UPDATE no action ON DELETE no action
FOREIGN KEY (`resourceId`) REFERENCES `resources`(`resourceId`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `users` (
@@ -55,5 +55,5 @@ CREATE TABLE `users` (
`name` text NOT NULL,
`email` text NOT NULL,
`groups` text,
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE no action
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE cascade
);

View File

@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "369f669c-f220-4706-9a5c-8a66ab5653b2",
"id": "379ca2f9-068a-4289-8a23-001e7dc269b1",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"exitNodes": {
@@ -83,10 +83,10 @@
"columns": {
"resourceId": {
"name": "resourceId",
"type": "integer",
"type": "text(2048)",
"primaryKey": true,
"notNull": true,
"autoincrement": true
"autoincrement": false
},
"siteId": {
"name": "siteId",
@@ -122,7 +122,7 @@
"columnsTo": [
"siteId"
],
"onDelete": "no action",
"onDelete": "cascade",
"onUpdate": "no action"
}
},
@@ -166,7 +166,7 @@
"columnsTo": [
"exitNodeId"
],
"onDelete": "no action",
"onDelete": "cascade",
"onUpdate": "no action"
}
},
@@ -238,7 +238,7 @@
"columnsTo": [
"orgId"
],
"onDelete": "no action",
"onDelete": "cascade",
"onUpdate": "no action"
},
"sites_exitNode_exitNodes_exitNodeId_fk": {
@@ -251,7 +251,7 @@
"columnsTo": [
"exitNodeId"
],
"onDelete": "no action",
"onDelete": "set null",
"onUpdate": "no action"
}
},
@@ -270,7 +270,7 @@
},
"resourceId": {
"name": "resourceId",
"type": "integer",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
@@ -316,7 +316,7 @@
"columnsTo": [
"resourceId"
],
"onDelete": "no action",
"onDelete": "cascade",
"onUpdate": "no action"
}
},
@@ -374,7 +374,7 @@
"columnsTo": [
"orgId"
],
"onDelete": "no action",
"onDelete": "cascade",
"onUpdate": "no action"
}
},

View File

@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1727551266674,
"tag": "0000_unique_killraven",
"when": 1727557783608,
"tag": "0000_wealthy_captain_midlands",
"breakpoints": true
}
]