-- 1. 创建主键自增序列
CREATE SEQUENCE adm_frequency_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

/*
 Navicat Premium Dump SQL

 Source Server         : 189信创HIS
 Source Server Type    : PostgreSQL
 Source Server Version : 160002 (160002)
 Source Host           : 1.183.189.95:8020
 Source Catalog        : openhis
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 160002 (160002)
 File Encoding         : 65001

 Date: 20/08/2025 15:21:12
*/


-- ----------------------------
-- Table structure for adm_frequency
-- ----------------------------
DROP TABLE IF EXISTS "adm_frequency";
CREATE TABLE "adm_frequency" (
  "id" int8 NOT NULL DEFAULT nextval('adm_frequency_id_seq'::regclass),
  "rate_code" varchar(50) COLLATE "pg_catalog"."default",
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "day_count" int4,
  "day_interval" int4,
  "day_times" varchar(255) COLLATE "pg_catalog"."default",
  "week_cycle_flag" int4 DEFAULT 0,
  "week_interval" int4,
  "week_times" int4,
  "continue_flag" int4 DEFAULT 0,
  "total_execution_count" int4 DEFAULT 0,
  "execution_period" int4,
  "execution_period_unit" varchar(20) COLLATE "pg_catalog"."default",
  "third_code" varchar(255) COLLATE "pg_catalog"."default",
  "memo" varchar(1000) COLLATE "pg_catalog"."default",
  "concurrency_stamp" int4,
  "tenant_id" int8 NOT NULL,
  "delete_flag" char(1) COLLATE "pg_catalog"."default" DEFAULT '0'::bpchar,
  "create_by" varchar(32) COLLATE "pg_catalog"."default",
  "create_time" timestamptz(6) DEFAULT now(),
  "update_by" varchar(32) COLLATE "pg_catalog"."default",
  "update_time" timestamptz(6) DEFAULT now()
)
;
COMMENT ON COLUMN "adm_frequency"."id" IS '唯一标识符';
COMMENT ON COLUMN "adm_frequency"."rate_code" IS '频次代码，唯一标识与字典表对应';
COMMENT ON COLUMN "adm_frequency"."name" IS '频次名称';
COMMENT ON COLUMN "adm_frequency"."day_count" IS '每天执行的次数';
COMMENT ON COLUMN "adm_frequency"."day_interval" IS '每次执行之间的间隔（天数）';
COMMENT ON COLUMN "adm_frequency"."day_times" IS '每天的具体执行时间点，逗号分隔';
COMMENT ON COLUMN "adm_frequency"."week_cycle_flag" IS '是否周期性每周执行，0 为否，1 为是';
COMMENT ON COLUMN "adm_frequency"."week_interval" IS '每周执行的间隔，单位为周';
COMMENT ON COLUMN "adm_frequency"."week_times" IS '每周执行的次数';
COMMENT ON COLUMN "adm_frequency"."continue_flag" IS '是否为连续执行，0 为否，1 为是';
COMMENT ON COLUMN "adm_frequency"."total_execution_count" IS '执行总次数，记录任务累计执行次数';
COMMENT ON COLUMN "adm_frequency"."execution_period" IS '任务执行周期长度';
COMMENT ON COLUMN "adm_frequency"."execution_period_unit" IS '任务执行周期的单位，如 day、week、month';
COMMENT ON COLUMN "adm_frequency"."third_code" IS '第三方代码，外部系统使用';
COMMENT ON COLUMN "adm_frequency"."memo" IS '备注信息';
COMMENT ON COLUMN "adm_frequency"."concurrency_stamp" IS '并发戳，用于版本控制和并发冲突检测';
COMMENT ON COLUMN "adm_frequency"."tenant_id" IS '租户ID，标识所属租户';
COMMENT ON COLUMN "adm_frequency"."delete_flag" IS '删除标记，1 表示已删除，0 表示未删除';
COMMENT ON COLUMN "adm_frequency"."create_by" IS '创建人';
COMMENT ON COLUMN "adm_frequency"."create_time" IS '创建时间';
COMMENT ON COLUMN "adm_frequency"."update_by" IS '更新人';
COMMENT ON COLUMN "adm_frequency"."update_time" IS '更新时间';
COMMENT ON TABLE "adm_frequency" IS '频次配置表，用于频次、周期和相关信息';

-- ----------------------------
-- Records of adm_frequency
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table adm_frequency
-- ----------------------------
ALTER TABLE "adm_frequency" ADD CONSTRAINT "adm_frequency_pkey" PRIMARY KEY ("id");



-- 向迁移历史表插入记录
INSERT INTO __MigrationsHistory (MigrationId, ProductVersion)
VALUES ('202508201044 adm_frequency', '1.0.0');