CREATE SERVER IF NOT EXISTS "mysql_real" FOREIGN DATA WRAPPER "mysql_fdw" OPTIONS ( host 'rm-bp13y52rav2jc6952o.mysql.rds.aliyuncs.com', port '3306');
CREATE USER MAPPING IF NOT EXISTS FOR "root" SERVER "mysql_real" OPTIONS (username 'fdw_readonly', password 'Fxft123456');

-- ----------------------------
-- Table structure for jxc_custom
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_custom" (
  "custom_no" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "status" int2 NOT NULL,
  "del" int2 NOT NULL,
  "create_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "update_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_custom');

-- ----------------------------
-- Table structure for jxc_custom_order
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_custom_order" (
  "sn" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "custom_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "pay_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "transaction_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "sim_count" int4 NOT NULL,
  "amount_money" float8 NOT NULL,
  "paytype" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "status" int2 NOT NULL,
  "pay_time" varchar(19) NOT NULL,
  "create_date" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "create_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "update_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_custom_order');

-- ----------------------------
-- Table structure for jxc_custom_order_item
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_custom_order_item" (
  "sn" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "sim" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "goods_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "goods_name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "goods_type" int2 NOT NULL,
  "unit_price" float8 NOT NULL,
  "amount_price" float8 NOT NULL,
  "quantity" int4 NOT NULL,
  "custom_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "create_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_custom_order_item');

-- ----------------------------
-- Table structure for jxc_order
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_order" (
  "o_number" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "o_card_use" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "o_customer_number" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "o_customer_relation_id" int4 NOT NULL,
  "o_customer_name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "o_p_number" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "o_p_name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "o_price" float8 NOT NULL,
  "o_hastest" int2 NOT NULL,
  "o_has_empty" int2 NOT NULL,
  "o_testing_period_type" int2 NOT NULL,
  "o_test_time" int4 NOT NULL,
  "o_testing_period_start" date NOT NULL,
  "o_testing_period_end" date NOT NULL,
  "o_test_flows_type" varchar(10) COLLATE "pg_catalog"."default",
  "o_test_flows" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "o_test_msg" int4 NOT NULL,
  "o_silent_period_type" int2,
  "o_silent_time" int4 NOT NULL,
  "o_silent_period_start" date NOT NULL,
  "o_silent_period_end" date NOT NULL,
  "o_renewal_price" float8 NOT NULL,
  "o_number_type" int2 NOT NULL,
  "o_card_counts" int4 NOT NULL,
  "o_amount" float8 NOT NULL,
  "o_create_date" date NOT NULL,
  "o_remark" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "o_status" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "o_delivery_man" int4 NOT NULL,
  "o_delivery_time" varchar(19) NOT NULL,
  "o_is_del" int2 NOT NULL,
  "o_create_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "o_update_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_order');

-- ----------------------------
-- Table structure for jxc_order_single_row
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_order_single_row" (
  "s_id" int4 NOT NULL,
  "s_number" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "o_number" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "s_card_counts" int4 NOT NULL,
  "s_status" int2 NOT NULL,
  "s_remark" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "s_create_time" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "s_update_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_order_single_row');

-- ----------------------------
-- Table structure for jxc_order_single_row_item
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_order_single_row_item" (
  "i_id" int4 NOT NULL,
  "s_number" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "s_out_number" int4 NOT NULL,
  "s_batch_number" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "s_section_number" text COLLATE "pg_catalog"."default" NOT NULL,
  "s_sim_start" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "s_is_serial" int2 NOT NULL,
  "i_status" int2 NOT NULL,
  "i_remark" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_order_single_row_item');

-- ----------------------------
-- Table structure for jxc_package
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package" (
  "package_sn" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "type" int2 NOT NULL,
  "carrieroperator" varchar(2) COLLATE "pg_catalog"."default" NOT NULL,
  "price" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "guide_price" varchar(10) COLLATE "pg_catalog"."default",
  "flows" varchar(255) COLLATE "pg_catalog"."default",
  "voices" int4,
  "short_msg" int4,
  "short_msg_on" int2,
  "lbs" int2,
  "flow_cycle" int4,
  "package_cycle" int4,
  "status" int2 NOT NULL,
  "del" int2 NOT NULL,
  "create_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL,
  "update_time" varchar(11) COLLATE "pg_catalog"."default" NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package');

-- ----------------------------
-- Table structure for jxc_package_addoptional
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_addoptional" (
  "bag_number" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "type_content" varchar(50) COLLATE "pg_catalog"."default",
  "content_count" varchar(100) COLLATE "pg_catalog"."default",
  "content_unit" varchar(20) COLLATE "pg_catalog"."default",
  "service_cycle" int4,
  "reset_cycle" int4,
  "guide_price" numeric,
  "effect_immediate" int2,
  "package_remark" varchar(100) COLLATE "pg_catalog"."default",
  "status" "real"."status_t",
  "del" "real"."del_t",
  "create_time" varchar(19),
  "update_time" varchar(19)
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_addoptional');

-- ----------------------------
-- Table structure for jxc_package_custom_relation
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_custom_relation" (
  "custom_no" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "package_sn" varchar(30) COLLATE "pg_catalog"."default" NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_custom_relation');

-- ----------------------------
-- Table structure for jxc_package_flows
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_flows" (
  "bag_number" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "carrieroperator" char(2) COLLATE "pg_catalog"."default",
  "flows" int4,
  "short_msg" int4,
  "voices" int4,
  "lbs" int2,
  "flows_cycle" int4,
  "service_cycle" int4 NOT NULL,
  "price" numeric NOT NULL,
  "guide_price" numeric,
  "effect_immediate" int2,
  "operator" int4 NOT NULL,
  "status" "real"."status_t" NOT NULL,
  "del" "real"."del_t" NOT NULL,
  "create_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_flows');

-- ----------------------------
-- Table structure for jxc_package_optional
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_optional" (
  "bag_number" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "carrieroperator" char(2) COLLATE "pg_catalog"."default",
  "flows" int4,
  "short_msg" int4,
  "voices" int4,
  "lbs" int2,
  "flows_cycle" int4,
  "service_cycle" int4 NOT NULL,
  "price" numeric NOT NULL,
  "guide_price" numeric,
  "effect_immediate" int2,
  "base_service_cycle_extend" int2,
  "remark" text COLLATE "pg_catalog"."default",
  "status" "real"."status_t" NOT NULL,
  "del" "real"."del_t" NOT NULL,
  "create_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_optional');

-- ----------------------------
-- Table structure for jxc_package_renewal
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_renewal" (
  "bag_number" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "package_sn" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "service_cycle" int4 NOT NULL,
  "price" numeric NOT NULL,
  "guide_price" numeric,
  "effect_immediate" int2,
  "remark" text COLLATE "pg_catalog"."default",
  "status" "real"."status_t" NOT NULL,
  "del" "real"."del_t" NOT NULL,
  "create_time" varchar(19) NOT NULL
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_renewal');

-- ----------------------------
-- Table structure for jxc_package_value_add_relation
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_package_value_add_relation" (
  "id" int4 NOT NULL,
  "type" int2 NOT NULL,
  "custom_no" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "package_sn" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "package_name" varchar(100) COLLATE "pg_catalog"."default",
  "value_add_id" int4 NOT NULL,
  "value_add_number" varchar(30) COLLATE "pg_catalog"."default" NOT NULL,
  "value_add_name" varchar(100) COLLATE "pg_catalog"."default",
  "wx_package_show" int2,
  "del" "real"."del_t",
  "create_time" varchar(19)
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_package_value_add_relation');

-- ----------------------------
-- Table structure for jxc_user
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_user" (
  "id" int4 NOT NULL,
  "username" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "nickname" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "last_login_time" int4,
  "last_login_ip" varchar(40) COLLATE "pg_catalog"."default",
  "email" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "phone" varchar(20) COLLATE "pg_catalog"."default",
  "parent_user" int4,
  "role_tag" varchar(10) COLLATE "pg_catalog"."default",
  "status" int2,
  "del" int2 NOT NULL,
  "create_time" int4,
  "update_time" int4
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_user');

-- ----------------------------
-- Table structure for jxc_user_custom_relation
-- ----------------------------
CREATE FOREIGN TABLE IF NOT EXISTS "real"."jxc_user_custom_relation" (
  "uid" int4,
  "custom_no" varchar(20) COLLATE "pg_catalog"."default"
) SERVER "mysql_real" OPTIONS ("dbname" 'ckb_jxc', "table_name" 'jxc_user_custom_relation');