thunderhub/drizzle/sqlite/0001_fixed_nightshade.sql
2026-04-02 14:28:13 -06:00

25 lines
No EOL
1 KiB
SQL

CREATE TABLE `nodes` (
`id` text PRIMARY KEY NOT NULL,
`team_id` text NOT NULL,
`name` text NOT NULL,
`type` text NOT NULL,
`network` text NOT NULL,
`socket` text NOT NULL,
`encrypted_macaroon` text,
`encrypted_cert` text,
`created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
`updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `user_nodes` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`node_id` text NOT NULL,
`created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
`updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_nodes_user_id_node_id_unique` ON `user_nodes` (`user_id`,`node_id`);