Skip to content

Commit

Permalink
feat: save connection on the cloud with encryption (#27)
Browse files Browse the repository at this point in the history
* rework local connection manager

* feat: add edit connection local storage

* fixing the server-side error

* feat: add remove connection

* add key generation

* add migration

* feat: add query

* feat: add proxy query

* remove all console.log

* feat: delete and update database

* update remote connection

* feat: add remove connection

* add remote connection

* finish the header
  • Loading branch information
invisal authored Mar 19, 2024
1 parent 3f517c1 commit 1402d75
Show file tree
Hide file tree
Showing 49 changed files with 4,012 additions and 363 deletions.
57 changes: 57 additions & 0 deletions drizzle/0002_aspiring_shotgun.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
CREATE TABLE `database` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`name` text,
`description` text,
`color` text DEFAULT 'gray',
`driver` text DEFAULT 'turso',
`host` text,
`token` text,
`created_at` integer,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `database_role` (
`id` text PRIMARY KEY NOT NULL,
`database_id` text NOT NULL,
`name` text,
`can_execute_query` integer DEFAULT 0,
`created_by` text,
`created_at` integer,
`updated_by` text,
`updated_at` integer,
FOREIGN KEY (`database_id`) REFERENCES `database`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`created_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`updated_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `database_role_permission` (
`id` text PRIMARY KEY NOT NULL,
`role_id` text NOT NULL,
`role` text,
`access` text,
`table_name` text,
`column_name` text,
`created_by` text,
`created_at` integer,
`updated_by` text,
`updated_at` integer,
FOREIGN KEY (`role_id`) REFERENCES `database_role`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`created_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`updated_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `database_user_role` (
`user_id` text,
`database_id` text,
`role_id` text,
`created_at` integer,
PRIMARY KEY(`database_id`, `user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`database_id`) REFERENCES `database`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`role_id`) REFERENCES `database_role`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `database_user_idx` ON `database` (`user_id`);--> statement-breakpoint
CREATE INDEX `database_role_idx` ON `database_role` (`database_id`);--> statement-breakpoint
CREATE INDEX `role_permission_table_idx` ON `database_role_permission` (`role_id`,`table_name`);
2 changes: 2 additions & 0 deletions drizzle/0003_dashing_marauders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE database_role ADD `is_owner` integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE database_user_role ADD `created_by` text REFERENCES user(id);
1 change: 1 addition & 0 deletions drizzle/0004_misty_the_professor.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE database ADD `deleted_at` integer;
Loading

0 comments on commit 1402d75

Please sign in to comment.