/*
 Navicat Premium Dump SQL

 Source Server         : localhost_5432
 Source Server Type    : PostgreSQL
 Source Server Version : 170000 (170000)
 Source Host           : localhost:5432
 Source Catalog        : verich
 Source Schema         : public

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

 Date: 27/10/2025 23:25:57
*/


-- ----------------------------
-- Sequence structure for update_plan_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."update_plan_id_seq";
CREATE SEQUENCE "public"."update_plan_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 2147483647
START 1
CACHE 1;

-- ----------------------------
-- Table structure for stock_adjust_factor_tushare
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_adjust_factor_tushare";
CREATE TABLE "public"."stock_adjust_factor_tushare" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_date" timestamp(0) NOT NULL,
  "adj_factor" numeric(10,3)
)
;

-- ----------------------------
-- Table structure for stock_calendar
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_calendar";
CREATE TABLE "public"."stock_calendar" (
  "exchange" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "date" timestamp(0) NOT NULL,
  "is_open" bool,
  "pretrade_date" date
)
;
COMMENT ON COLUMN "public"."stock_calendar"."exchange" IS '交易所';
COMMENT ON COLUMN "public"."stock_calendar"."date" IS '日历日期';
COMMENT ON COLUMN "public"."stock_calendar"."is_open" IS '是否开市';
COMMENT ON COLUMN "public"."stock_calendar"."pretrade_date" IS '上个交易日';

-- ----------------------------
-- Table structure for stock_daily
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_daily";
CREATE TABLE "public"."stock_daily" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_date" timestamp(0) NOT NULL,
  "open" numeric(23,3) DEFAULT NULL::numeric,
  "high" numeric(23,3) DEFAULT NULL::numeric,
  "low" numeric(23,3) DEFAULT NULL::numeric,
  "close" numeric(23,3) DEFAULT NULL::numeric,
  "pre_close" numeric(23,3) DEFAULT NULL::numeric,
  "change" numeric(23,3) DEFAULT NULL::numeric,
  "pct_chg" numeric(23,3) DEFAULT NULL::numeric,
  "vol" numeric(23,3) DEFAULT NULL::numeric,
  "amount" numeric(23,3) DEFAULT NULL::numeric
)
;
COMMENT ON COLUMN "public"."stock_daily"."ts_code" IS '股票代码';
COMMENT ON COLUMN "public"."stock_daily"."trade_date" IS '交易日期';
COMMENT ON COLUMN "public"."stock_daily"."open" IS '开盘';
COMMENT ON COLUMN "public"."stock_daily"."high" IS '最高';
COMMENT ON COLUMN "public"."stock_daily"."low" IS '最低';
COMMENT ON COLUMN "public"."stock_daily"."close" IS '收盘';
COMMENT ON COLUMN "public"."stock_daily"."pre_close" IS '昨收';
COMMENT ON COLUMN "public"."stock_daily"."change" IS '涨跌额';
COMMENT ON COLUMN "public"."stock_daily"."pct_chg" IS '涨跌幅（未复权）';
COMMENT ON COLUMN "public"."stock_daily"."vol" IS '成交量(手)';
COMMENT ON COLUMN "public"."stock_daily"."amount" IS '成交额(千元)';

-- ----------------------------
-- Table structure for stock_daily_basic_tushare
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_daily_basic_tushare";
CREATE TABLE "public"."stock_daily_basic_tushare" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_date" timestamp(0) NOT NULL,
  "close" numeric(23,3) DEFAULT NULL::numeric,
  "turnover_rate" numeric(23,3) DEFAULT NULL::numeric,
  "turnover_rate_f" numeric(23,3) DEFAULT NULL::numeric,
  "volume_ratio" numeric(23,3) DEFAULT NULL::numeric,
  "pe" numeric(23,3) DEFAULT NULL::numeric,
  "pe_ttm" numeric(23,3) DEFAULT NULL::numeric,
  "pb" numeric(23,3) DEFAULT NULL::numeric,
  "ps" numeric(23,3) DEFAULT NULL::numeric,
  "ps_ttm" numeric(23,3) DEFAULT NULL::numeric,
  "dv_ratio" numeric(23,3) DEFAULT NULL::numeric,
  "dv_ttm" numeric(23,3) DEFAULT NULL::numeric,
  "total_share" numeric(23,3) DEFAULT NULL::numeric,
  "float_share" numeric(23,3) DEFAULT NULL::numeric,
  "free_share" numeric(23,3) DEFAULT NULL::numeric,
  "total_mv" numeric(23,3) DEFAULT NULL::numeric,
  "circ_mv" numeric(23,3) DEFAULT NULL::numeric
)
;

-- ----------------------------
-- Table structure for stock_holder
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_holder";
CREATE TABLE "public"."stock_holder" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "ann_date" date NOT NULL,
  "end_date" timestamp(0) NOT NULL,
  "holder_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "hold_amount" numeric(23,3) NOT NULL,
  "hold_ratio" numeric(23,3) DEFAULT NULL::numeric,
  "holder_type" int2 NOT NULL DEFAULT 0
)
;

-- ----------------------------
-- Table structure for stock_info
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_info";
CREATE TABLE "public"."stock_info" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "list_status" varchar(1) COLLATE "pg_catalog"."default",
  "list_date" timestamp(0),
  "delist_date" timestamp(0)
)
;
COMMENT ON COLUMN "public"."stock_info"."ts_code" IS '股票代码';
COMMENT ON COLUMN "public"."stock_info"."name" IS '股票名称';
COMMENT ON COLUMN "public"."stock_info"."list_status" IS '上市状态';
COMMENT ON COLUMN "public"."stock_info"."list_date" IS '上市时间';
COMMENT ON COLUMN "public"."stock_info"."delist_date" IS '退市时间';

-- ----------------------------
-- Table structure for stock_limit
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_limit";
CREATE TABLE "public"."stock_limit" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_date" timestamp(0) NOT NULL,
  "industry" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "name" varchar(20) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "close" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "pct_chg" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "amount" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "limit_amount" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "float_mv" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "total_mv" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "turnover_ratio" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "fd_amount" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "first_time" timestamp(6),
  "last_time" timestamp(6),
  "open_times" int8,
  "up_stat" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "limit_times" int8,
  "limit" varchar(1) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying
)
;
COMMENT ON COLUMN "public"."stock_limit"."ts_code" IS '股票代码';
COMMENT ON COLUMN "public"."stock_limit"."trade_date" IS '交易日期';
COMMENT ON COLUMN "public"."stock_limit"."industry" IS '所属行业';
COMMENT ON COLUMN "public"."stock_limit"."name" IS '股票名称';
COMMENT ON COLUMN "public"."stock_limit"."close" IS '收盘价';
COMMENT ON COLUMN "public"."stock_limit"."pct_chg" IS '涨跌幅';
COMMENT ON COLUMN "public"."stock_limit"."amount" IS '成交额';
COMMENT ON COLUMN "public"."stock_limit"."limit_amount" IS '板上成交金额(涨停无此数据)';
COMMENT ON COLUMN "public"."stock_limit"."float_mv" IS '流通市值';
COMMENT ON COLUMN "public"."stock_limit"."total_mv" IS '总市值';
COMMENT ON COLUMN "public"."stock_limit"."turnover_ratio" IS '换手率';
COMMENT ON COLUMN "public"."stock_limit"."fd_amount" IS '封单金额';
COMMENT ON COLUMN "public"."stock_limit"."first_time" IS '首次封板时间(跌停无此数据)';
COMMENT ON COLUMN "public"."stock_limit"."last_time" IS '最后封板时间';
COMMENT ON COLUMN "public"."stock_limit"."open_times" IS '涨停炸板/跌停开板次数';
COMMENT ON COLUMN "public"."stock_limit"."up_stat" IS '涨停统计(N/T，T日有N次涨停)';
COMMENT ON COLUMN "public"."stock_limit"."limit_times" IS '连板数';
COMMENT ON COLUMN "public"."stock_limit"."limit" IS 'D跌停U涨停Z炸板';

-- ----------------------------
-- Table structure for stock_minute
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_minute";
CREATE TABLE "public"."stock_minute" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_time" timestamp(6) NOT NULL,
  "freq" int4 NOT NULL,
  "open" numeric(23,3) DEFAULT NULL::numeric,
  "high" numeric(23,3) DEFAULT NULL::numeric,
  "close" numeric(23,3) DEFAULT NULL::numeric,
  "low" numeric(23,3) DEFAULT NULL::numeric,
  "vol" numeric(23,3) DEFAULT NULL::numeric,
  "amount" numeric(23,3) DEFAULT NULL::numeric
)
;

-- ----------------------------
-- Table structure for stock_ths_daily
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_ths_daily";
CREATE TABLE "public"."stock_ths_daily" (
  "ts_code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "trade_date" timestamp(0) NOT NULL,
  "close" numeric(23,3) DEFAULT NULL::numeric,
  "open" numeric(23,3) DEFAULT NULL::numeric,
  "high" numeric(23,3) DEFAULT NULL::numeric,
  "low" numeric(23,3) DEFAULT NULL::numeric,
  "pre_close" numeric(23,3) DEFAULT NULL::numeric,
  "avg_price" numeric(23,3) DEFAULT NULL::numeric,
  "change" numeric(23,3) DEFAULT NULL::numeric,
  "pct_change" numeric(23,3) DEFAULT NULL::numeric,
  "vol" numeric(23,3) DEFAULT NULL::numeric,
  "turnover_rate" numeric(23,3) DEFAULT NULL::numeric,
  "total_mv" numeric(23,3) DEFAULT NULL::numeric,
  "float_mv" numeric(23,3) DEFAULT NULL::numeric
)
;

-- ----------------------------
-- Table structure for stock_ths_list
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_ths_list";
CREATE TABLE "public"."stock_ths_list" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "count" int4,
  "exchange" varchar(255) COLLATE "pg_catalog"."default",
  "list_date" timestamp(0),
  "type" varchar(5) COLLATE "pg_catalog"."default"
)
;

-- ----------------------------
-- Table structure for stock_ths_member
-- ----------------------------
DROP TABLE IF EXISTS "public"."stock_ths_member";
CREATE TABLE "public"."stock_ths_member" (
  "ts_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "con_code" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "con_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "weight" numeric(10,2) DEFAULT NULL::numeric,
  "in_date" date,
  "out_date" date,
  "is_new" varchar(1) COLLATE "pg_catalog"."default" NOT NULL
)
;

-- ----------------------------
-- Table structure for update_plan
-- ----------------------------
DROP TABLE IF EXISTS "public"."update_plan";
CREATE TABLE "public"."update_plan" (
  "id" int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 2147483647
START 1
CACHE 1
),
  "cron_expr" varchar(255) COLLATE "pg_catalog"."default",
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "methods" text COLLATE "pg_catalog"."default",
  "open_day_check" bool,
  "enabled" bool
)
;

-- ----------------------------
-- Table structure for web_user
-- ----------------------------
DROP TABLE IF EXISTS "public"."web_user";
CREATE TABLE "public"."web_user" (
  "user_id" int4 NOT NULL,
  "username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "nickname" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "password" varchar(255) COLLATE "pg_catalog"."default",
  "last_login_time" timestamp(6),
  "last_login_ip" varchar(255) COLLATE "pg_catalog"."default"
)
;

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."update_plan_id_seq"
OWNED BY "public"."update_plan"."id";
SELECT setval('"public"."update_plan_id_seq"', 2, true);

-- ----------------------------
-- Primary Key structure for table stock_adjust_factor_tushare
-- ----------------------------
ALTER TABLE "public"."stock_adjust_factor_tushare" ADD CONSTRAINT "stock_adjust_factor_tushare_pkey" PRIMARY KEY ("ts_code", "trade_date");

-- ----------------------------
-- Primary Key structure for table stock_calendar
-- ----------------------------
ALTER TABLE "public"."stock_calendar" ADD CONSTRAINT "stock_calendar_pkey" PRIMARY KEY ("exchange", "date");

-- ----------------------------
-- Indexes structure for table stock_daily
-- ----------------------------
CREATE INDEX "index_tradeDate" ON "public"."stock_daily" USING btree (
  "trade_date" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);
CREATE INDEX "index_tsCode" ON "public"."stock_daily" USING btree (
  "ts_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "index_tsCode_tradeDate" ON "public"."stock_daily" USING btree (
  "ts_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "trade_date" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table stock_daily
-- ----------------------------
ALTER TABLE "public"."stock_daily" ADD CONSTRAINT "stock_daily_pkey" PRIMARY KEY ("ts_code", "trade_date");

-- ----------------------------
-- Indexes structure for table stock_daily_basic_tushare
-- ----------------------------
CREATE INDEX "index_stock_daily_basic_tradeDate" ON "public"."stock_daily_basic_tushare" USING btree (
  "trade_date" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);
CREATE INDEX "index_stock_daily_basic_tsCode" ON "public"."stock_daily_basic_tushare" USING btree (
  "ts_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "index_stock_daily_basic_tsCode_tradeDate" ON "public"."stock_daily_basic_tushare" USING btree (
  "ts_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "trade_date" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table stock_daily_basic_tushare
-- ----------------------------
ALTER TABLE "public"."stock_daily_basic_tushare" ADD CONSTRAINT "stock_daily_basic_tushare_pkey" PRIMARY KEY ("trade_date", "ts_code");

-- ----------------------------
-- Primary Key structure for table stock_holder
-- ----------------------------
ALTER TABLE "public"."stock_holder" ADD CONSTRAINT "stock_holder_pkey" PRIMARY KEY ("ts_code", "end_date", "holder_name", "holder_type");

-- ----------------------------
-- Primary Key structure for table stock_info
-- ----------------------------
ALTER TABLE "public"."stock_info" ADD CONSTRAINT "stock_info_pkey" PRIMARY KEY ("ts_code");

-- ----------------------------
-- Primary Key structure for table stock_limit
-- ----------------------------
ALTER TABLE "public"."stock_limit" ADD CONSTRAINT "stock_limit_pkey" PRIMARY KEY ("ts_code", "trade_date");

-- ----------------------------
-- Primary Key structure for table stock_minute
-- ----------------------------
ALTER TABLE "public"."stock_minute" ADD CONSTRAINT "stock_minute_pkey" PRIMARY KEY ("ts_code", "trade_time", "freq");

-- ----------------------------
-- Primary Key structure for table stock_ths_daily
-- ----------------------------
ALTER TABLE "public"."stock_ths_daily" ADD CONSTRAINT "stock_ths_daily_pkey" PRIMARY KEY ("ts_code", "trade_date");

-- ----------------------------
-- Primary Key structure for table stock_ths_list
-- ----------------------------
ALTER TABLE "public"."stock_ths_list" ADD CONSTRAINT "stock_ths_list_pkey" PRIMARY KEY ("ts_code");

-- ----------------------------
-- Primary Key structure for table stock_ths_member
-- ----------------------------
ALTER TABLE "public"."stock_ths_member" ADD CONSTRAINT "stock_ths_member_pkey" PRIMARY KEY ("ts_code", "con_code", "con_name");

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

-- ----------------------------
-- Primary Key structure for table web_user
-- ----------------------------
ALTER TABLE "public"."web_user" ADD CONSTRAINT "tangda_user_pkey" PRIMARY KEY ("user_id");
