mirror of
https://github.com/beilunyang/moemail.git
synced 2026-06-03 14:40:21 +08:00
feat: Implement role-based access control and enhance permissions system
This commit is contained in:
33
drizzle/0004_panoramic_hedge_knight.sql
Normal file
33
drizzle/0004_panoramic_hedge_knight.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
CREATE TABLE `permission` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`created_at` integer,
|
||||
`updated_at` integer
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `role_permission` (
|
||||
`role_id` text NOT NULL,
|
||||
`permission_id` text NOT NULL,
|
||||
`created_at` integer,
|
||||
PRIMARY KEY(`role_id`, `permission_id`),
|
||||
FOREIGN KEY (`role_id`) REFERENCES `role`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`permission_id`) REFERENCES `permission`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `role` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`created_at` integer,
|
||||
`updated_at` integer
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user_role` (
|
||||
`user_id` text NOT NULL,
|
||||
`role_id` text NOT NULL,
|
||||
`created_at` integer,
|
||||
PRIMARY KEY(`user_id`, `role_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`role_id`) REFERENCES `role`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
Reference in New Issue
Block a user