From b7bc797a99e70815e18e9110161b5171c6665b5a Mon Sep 17 00:00:00 2001 From: Owen Schwartz Date: Sat, 28 Sep 2024 11:52:51 -0400 Subject: [PATCH] Update migrations --- server/migrations/0000_lowly_robin_chapel.sql | 49 +++ server/migrations/0000_petite_zarda.sql | 9 - server/migrations/meta/0000_snapshot.json | 335 ++++++++++++++++-- server/migrations/meta/_journal.json | 4 +- 4 files changed, 348 insertions(+), 49 deletions(-) create mode 100644 server/migrations/0000_lowly_robin_chapel.sql delete mode 100644 server/migrations/0000_petite_zarda.sql diff --git a/server/migrations/0000_lowly_robin_chapel.sql b/server/migrations/0000_lowly_robin_chapel.sql new file mode 100644 index 00000000..2cf9334a --- /dev/null +++ b/server/migrations/0000_lowly_robin_chapel.sql @@ -0,0 +1,49 @@ +CREATE TABLE `exitNodes` ( + `exitNodeId` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text, + `address` integer +); +--> statement-breakpoint +CREATE TABLE `org` ( + `orgId` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text NOT NULL +); +--> statement-breakpoint +CREATE TABLE `resources` ( + `resourceId` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `siteId` integer, + `name` text, + `targetIp` text, + `method` text, + `port` integer, + `proto` text, + 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, + `subnet` integer, + `exitNodeId` integer, + 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, + `name` text, + `autoSubdomain` text, + `pubKey` integer, + `subnet` text, + `exitNode` integer, + FOREIGN KEY (`orgId`) REFERENCES `org`(`orgId`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`exitNode`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `users` ( + `uid` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `orgId` integer, + `name` text, + `email` text, + `groups` text, + FOREIGN KEY (`orgId`) REFERENCES `org`(`orgId`) ON UPDATE no action ON DELETE no action +); diff --git a/server/migrations/0000_petite_zarda.sql b/server/migrations/0000_petite_zarda.sql deleted file mode 100644 index ce65bec1..00000000 --- a/server/migrations/0000_petite_zarda.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE `proxyTargets` ( - `id` text PRIMARY KEY NOT NULL, - `target` text NOT NULL, - `rule` text NOT NULL, - `entryPoint` text NOT NULL, - `enabled` integer DEFAULT 1 NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX `proxyTargets_id_unique` ON `proxyTargets` (`id`); \ No newline at end of file diff --git a/server/migrations/meta/0000_snapshot.json b/server/migrations/meta/0000_snapshot.json index 68961190..11e8a859 100644 --- a/server/migrations/meta/0000_snapshot.json +++ b/server/migrations/meta/0000_snapshot.json @@ -1,61 +1,320 @@ { "version": "6", "dialect": "sqlite", - "id": "341a41b7-2cc2-4967-b0cf-ec35f6d0486a", + "id": "a06283ff-bd4b-4994-988c-4db3279f73dd", "prevId": "00000000-0000-0000-0000-000000000000", "tables": { - "proxyTargets": { - "name": "proxyTargets", + "exitNodes": { + "name": "exitNodes", "columns": { - "id": { - "name": "id", - "type": "text", + "exitNodeId": { + "name": "exitNodeId", + "type": "integer", "primaryKey": true, "notNull": true, - "autoincrement": false + "autoincrement": true }, - "target": { - "name": "target", + "name": { + "name": "name", "type": "text", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "rule": { - "name": "rule", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "entryPoint": { - "name": "entryPoint", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "enabled": { - "name": "enabled", + "address": { + "name": "address", "type": "integer", "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 1 - } - }, - "indexes": { - "proxyTargets_id_unique": { - "name": "proxyTargets_id_unique", - "columns": [ - "id" - ], - "isUnique": true + "notNull": false, + "autoincrement": false } }, + "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {} + }, + "org": { + "name": "org", + "columns": { + "orgId": { + "name": "orgId", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "resources": { + "name": "resources", + "columns": { + "resourceId": { + "name": "resourceId", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "siteId": { + "name": "siteId", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "targetIp": { + "name": "targetIp", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proto": { + "name": "proto", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "resources_siteId_sites_siteId_fk": { + "name": "resources_siteId_sites_siteId_fk", + "tableFrom": "resources", + "tableTo": "sites", + "columnsFrom": [ + "siteId" + ], + "columnsTo": [ + "siteId" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "routes": { + "name": "routes", + "columns": { + "routeId": { + "name": "routeId", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "subnet": { + "name": "subnet", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exitNodeId": { + "name": "exitNodeId", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "routes_exitNodeId_exitNodes_exitNodeId_fk": { + "name": "routes_exitNodeId_exitNodes_exitNodeId_fk", + "tableFrom": "routes", + "tableTo": "exitNodes", + "columnsFrom": [ + "exitNodeId" + ], + "columnsTo": [ + "exitNodeId" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sites": { + "name": "sites", + "columns": { + "siteId": { + "name": "siteId", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "orgId": { + "name": "orgId", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "autoSubdomain": { + "name": "autoSubdomain", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pubKey": { + "name": "pubKey", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subnet": { + "name": "subnet", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exitNode": { + "name": "exitNode", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "sites_orgId_org_orgId_fk": { + "name": "sites_orgId_org_orgId_fk", + "tableFrom": "sites", + "tableTo": "org", + "columnsFrom": [ + "orgId" + ], + "columnsTo": [ + "orgId" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sites_exitNode_exitNodes_exitNodeId_fk": { + "name": "sites_exitNode_exitNodes_exitNodeId_fk", + "tableFrom": "sites", + "tableTo": "exitNodes", + "columnsFrom": [ + "exitNode" + ], + "columnsTo": [ + "exitNodeId" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "uid": { + "name": "uid", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "orgId": { + "name": "orgId", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "groups": { + "name": "groups", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_orgId_org_orgId_fk": { + "name": "users_orgId_org_orgId_fk", + "tableFrom": "users", + "tableTo": "org", + "columnsFrom": [ + "orgId" + ], + "columnsTo": [ + "orgId" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} } }, "enums": {}, diff --git a/server/migrations/meta/_journal.json b/server/migrations/meta/_journal.json index 0d088155..604bb4c3 100644 --- a/server/migrations/meta/_journal.json +++ b/server/migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "6", - "when": 1727489319772, - "tag": "0000_petite_zarda", + "when": 1727538753952, + "tag": "0000_lowly_robin_chapel", "breakpoints": true } ]