Files
affiliate_dash/backend/internal/database/migrations/007_merchant_roles.sql
T

17 lines
607 B
SQL

-- 商户自定义员工角色。role code 仅在所属商户内唯一,权限以逗号分隔保存。
CREATE TABLE IF NOT EXISTS merchant_roles (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMPTZ,
updated_at TIMESTAMPTZ,
merchant_id BIGINT NOT NULL,
code VARCHAR(64) NOT NULL,
name VARCHAR(64) NOT NULL,
permissions TEXT NOT NULL DEFAULT '',
status BIGINT NOT NULL DEFAULT 1
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_merchant_role_code
ON merchant_roles (merchant_id, code);
CREATE INDEX IF NOT EXISTS idx_merchant_roles_merchant_id
ON merchant_roles (merchant_id);