/*
 Navicat Premium Data Transfer

 Source Server         : 智慧法务
 Source Server Type    : PostgreSQL
 Source Server Version : 170005
 Source Host           : nas.7bm.co:54302
 Source Catalog        : docauditai
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 170005
 File Encoding         : 65001

 Date: 20/07/2025 19:51:40
*/


-- ----------------------------
-- Table structure for role_route
-- ----------------------------
DROP TABLE IF EXISTS "public"."role_route";
CREATE TABLE "public"."role_route" (
  "id" int4 NOT NULL DEFAULT nextval('role_route_id_seq'::regclass),
  "role_id" int4 NOT NULL,
  "route_id" int4 NOT NULL,
  "permission" varchar(10) COLLATE "pg_catalog"."default" DEFAULT 'RW'::character varying,
  "created_at" timestamptz(6) DEFAULT now(),
  "updated_at" timestamptz(6) DEFAULT now()
)
;
COMMENT ON COLUMN "public"."role_route"."id" IS '主键ID';
COMMENT ON COLUMN "public"."role_route"."role_id" IS '角色ID';
COMMENT ON COLUMN "public"."role_route"."route_id" IS '路由ID';
COMMENT ON COLUMN "public"."role_route"."permission" IS '权限类型(R=读, W=写, RW=读写)';
COMMENT ON COLUMN "public"."role_route"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."role_route"."updated_at" IS '更新时间';
COMMENT ON TABLE "public"."role_route" IS '角色-路由权限关联表';

-- ----------------------------
-- Triggers structure for table role_route
-- ----------------------------
CREATE TRIGGER "update_role_route_updated_at" BEFORE UPDATE ON "public"."role_route"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_updated_at"();

-- ----------------------------
-- Uniques structure for table role_route
-- ----------------------------
ALTER TABLE "public"."role_route" ADD CONSTRAINT "role_route_role_id_route_id_key" UNIQUE ("role_id", "route_id");

-- ----------------------------
-- Primary Key structure for table role_route
-- ----------------------------
ALTER TABLE "public"."role_route" ADD CONSTRAINT "role_route_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Keys structure for table role_route
-- ----------------------------
ALTER TABLE "public"."role_route" ADD CONSTRAINT "fk_role_route_role" FOREIGN KEY ("role_id") REFERENCES "public"."roles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "public"."role_route" ADD CONSTRAINT "fk_role_route_route" FOREIGN KEY ("route_id") REFERENCES "public"."sys_routes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
