Files
Neo-ZQYY/db/zqyy_app/scripts/create_test_db.sql

25 lines
1.1 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- 创建测试数据库 test_zqyy_app
-- 结构与生产 zqyy_app 完全一致(用户/权限/任务/审批)
-- 用途:开发和测试环境,避免影响生产数据
-- =============================================================================
-- 1. 创建数据库(需要以超级用户或有 CREATEDB 权限的角色执行)
-- 如果数据库已存在,先手动 DROP 或跳过此步
CREATE DATABASE test_zqyy_app
WITH ENCODING = 'UTF8'
LC_COLLATE = 'zh_CN.UTF-8'
LC_CTYPE = 'zh_CN.UTF-8'
TEMPLATE = template0;
-- 2. 连接到 test_zqyy_app 后,执行初始化脚本
-- 包含所有表定义users/roles/permissions/user_roles/role_permissions/tasks/approvals
--
-- 在 psql 中执行:
-- \c test_zqyy_app
-- \i ../schemas/init.sql
-- 注意事项:
-- - 生产 schema 变更后需同步在测试库执行相同的迁移脚本Requirements 9.4
-- - 迁移脚本位于 ../migrations/ 目录,按日期前缀顺序执行
-- - 所有业务表包含 site_id 字段,测试时注意设置正确的 site_id 值