|
|
-- == 表【area_rel_expireds】建视图语句 ==
|
|
|
-- drop view view_area_rel_expireds;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_area_rel_expireds') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_area_rel_expireds;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_area_rel_expireds as select area_code,latest_update_time,created_at,area_rel_expired_id,remark,module,expired_at,latest_check_at,notice_times from area_rel_expireds;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【belonging_regions】建视图语句 ==
|
|
|
-- drop view view_belonging_regions;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_belonging_regions') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_belonging_regions;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_belonging_regions as select belonging_region_id as id,belonging_region_id,customer_rel_id,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,customer_id,area_code,operator_id from belonging_regions;
|
|
|
-- pk belonging_region_id
|
|
|
-- jsonb operator,areas
|
|
|
|
|
|
|
|
|
-- == 表【area_belongs】建视图语句 ==
|
|
|
-- drop view view_area_belongs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_area_belongs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_area_belongs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_area_belongs as select area_belong_id as id,area_belong_id,begin_time,created_at,deleted_at,end_time,latest_update_time,updated_at,status,area_code,region_id,operator_id from area_belongs;
|
|
|
-- pk area_belong_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【area_categorys】建视图语句 ==
|
|
|
-- drop view view_area_categorys;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_area_categorys') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_area_categorys;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_area_categorys as select area_code,area_category_id,category_type,tag,begin_time,created_at,deleted_at,end_time,latest_update_time,updated_at,status,operator_id from area_categorys;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【channels】建视图语句 ==
|
|
|
-- drop view view_channels;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_channels') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_channels;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_channels as select channel_id as id,channel_id,channel_name,status,data_from,created_at,updated_at,deleted_at,latest_update_time from channels;
|
|
|
-- pk channel_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【chart_style_configs】建视图语句 ==
|
|
|
-- drop view view_chart_style_configs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_chart_style_configs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_chart_style_configs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_chart_style_configs as select id,conf,module,created_at,updated_at,data_conf from chart_style_configs;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【corresponding_period】建视图语句 ==
|
|
|
-- drop view view_corresponding_period;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_corresponding_period') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_corresponding_period;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_corresponding_period as select saleman_id as id,saleman_id,saleman_name,saleman_phone,saleman_year,saleman_month,opportunity,normal from corresponding_period;
|
|
|
-- pk saleman_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【change_logs】建视图语句 ==
|
|
|
-- drop view view_change_logs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_change_logs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_change_logs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_change_logs as select change_log_id as id,change_log_id,valid_period_begin,valid_period_end,rel_id,module_id,module,created_at,updated_at,deleted_at,latest_update_time,operator_id from change_logs;
|
|
|
-- pk change_log_id
|
|
|
-- jsonb change_log_content,operator
|
|
|
|
|
|
|
|
|
-- == 表【custom_relation_templates】建视图语句 ==
|
|
|
-- drop view view_custom_relation_templates;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_custom_relation_templates') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_custom_relation_templates;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_custom_relation_templates as select id,relation_main,relation_name,relation_type,is_require,created_at,latest_update_time,deleted_at from custom_relation_templates;
|
|
|
-- pk
|
|
|
-- jsonb relation_target,share_target
|
|
|
|
|
|
|
|
|
-- == 表【custom_relations】建视图语句 ==
|
|
|
-- drop view view_custom_relations;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_custom_relations') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_custom_relations;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_custom_relations as select id,relation_name,relation_main,relation_main_id,customer_id,product_id,channel_id,salesman_id,begin_time,end_time,area_code,regin_id,group_id,shared_value,shared_object,relation_object,operater_id,template_id,created_at,latest_update_time,deleted_at,status from custom_relations;
|
|
|
-- pk
|
|
|
-- jsonb areas
|
|
|
|
|
|
|
|
|
-- == 表【customer_rels】建视图语句 ==
|
|
|
-- drop view view_customer_rels;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_customer_rels') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_customer_rels;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_customer_rels as select customer_rel_id as id,customer_rel_id,customer_id,customer_level,status,created_at,updated_at,deleted_at,latest_update_time,operator_id from customer_rels;
|
|
|
-- pk customer_rel_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【customer_rewards】建视图语句 ==
|
|
|
-- drop view view_customer_rewards;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_customer_rewards') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_customer_rewards;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_customer_rewards as select customer_reward_id as id,customer_reward_id,data_from,reward_ratio,status,customer_id,salesman_id,created_at,updated_at,disabled_at,operator_id,latest_update_time from customer_rewards;
|
|
|
-- pk customer_reward_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【customers】建视图语句 ==
|
|
|
-- drop view view_customers;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_customers') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_customers;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_customers as select customer_id as id,customer_id,customer_code,customer_name,data_from,status,company_id,created_at,updated_at,deleted_at,latest_update_time,operator_id from customers;
|
|
|
-- pk customer_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【matched_relations】建视图语句 ==
|
|
|
-- drop view view_matched_relations;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_matched_relations') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_matched_relations;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_matched_relations as select matched_relation_id as id,matched_relation_id,matched_module_code,created_at,deleted_at,updated_at from matched_relations;
|
|
|
-- pk matched_relation_id
|
|
|
-- jsonb matched_fields,operator
|
|
|
|
|
|
|
|
|
-- == 表【notice_messages】建视图语句 ==
|
|
|
-- drop view view_notice_messages;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_notice_messages') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_notice_messages;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_notice_messages as select notice_message_id as id,notice_message_id,notice_message_title,notice_message_content,notice_message_module_id,notice_message_module,notice_message_sub_module_id,notice_message_sub_module,notice_message_type,status,created_at,updated_at,deleted_at,latest_update_time,operator_id from notice_messages;
|
|
|
-- pk notice_message_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【performances】建视图语句 ==
|
|
|
-- drop view view_performances;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_performances') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_performances;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_performances as select performance_id as id,performance_id,performance_value,performance_type,data_from,salesman_id,region_id,year,month,operator_id,created_at,updated_at,deleted_at,latest_update_time from performances;
|
|
|
-- pk performance_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【product_belongs】建视图语句 ==
|
|
|
-- drop view view_product_belongs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_belongs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_belongs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_belongs as select product_belong_id as id,product_belong_id,begin_time,end_time,product_id,status,parent_product_id,operator_id,created_at,deleted_at,latest_update_time,updated_at from product_belongs;
|
|
|
-- pk product_belong_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【corresponding_profit】建视图语句 ==
|
|
|
-- drop view view_corresponding_profit;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_corresponding_profit') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_corresponding_profit;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_corresponding_profit as select saleman_id as id,saleman_id,saleman_name,saleman_phone,saleman_year,saleman_month,opportunity,normal from corresponding_profit;
|
|
|
-- pk saleman_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【custom_relation_historys】建视图语句 ==
|
|
|
-- drop view view_custom_relation_historys;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_custom_relation_historys') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_custom_relation_historys;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_custom_relation_historys as select id,created_at,custom_relation_id,group_id,template_id,updated_at,relation_main,relation_main_id from custom_relation_historys;
|
|
|
-- pk
|
|
|
-- jsonb body_data,head_field
|
|
|
|
|
|
|
|
|
-- == 表【product_rel_expireds】建视图语句 ==
|
|
|
-- drop view view_product_rel_expireds;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_rel_expireds') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_rel_expireds;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_rel_expireds as select product_id as id,product_id,latest_update_time,created_at,product_rel_expired_id,remark,module,expired_at,latest_check_at,notice_times from product_rel_expireds;
|
|
|
-- pk product_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【product_rels】建视图语句 ==
|
|
|
-- drop view view_product_rels;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_rels') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_rels;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_rels as select product_rel_id as id,product_rel_id,product_id,product_level,operator_id,created_at,deleted_at,updated_at,latest_update_time from product_rels;
|
|
|
-- pk product_rel_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【product_categorys】建视图语句 ==
|
|
|
-- drop view view_product_categorys;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_categorys') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_categorys;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_categorys as select product_category_id as id,product_category_id,begin_time,end_time,product_id,status,category_type,tag,operator_id,created_at,deleted_at,updated_at,latest_update_time from product_categorys;
|
|
|
-- pk product_category_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【product_costs】建视图语句 ==
|
|
|
-- drop view view_product_costs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_costs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_costs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_costs as select product_cost_id as id,product_cost_id,created_at,deleted_at,data_from,updated_at,product_id,begin_time,cost,end_time,operator_id,latest_update_time from product_costs;
|
|
|
-- pk product_cost_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【profits】建视图语句 ==
|
|
|
-- drop view view_profits;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_profits') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_profits;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_profits as select profit_id as id,profit_id,profit_type,profit_value,data_from,salesman_id,region_id,operator_id,year,month,created_at,updated_at,deleted_at,latest_update_time from profits;
|
|
|
-- pk profit_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【products】建视图语句 ==
|
|
|
-- drop view view_products;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_products') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_products;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_products as select product_id as id,product_id,created_at,data_from,updated_at,product_code,product_name,standard,status,operator_id,latest_update_time,disabled_at from products;
|
|
|
-- pk product_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【region_rel_expireds】建视图语句 ==
|
|
|
-- drop view view_region_rel_expireds;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_region_rel_expireds') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_region_rel_expireds;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_region_rel_expireds as select region_id as id,region_id,latest_update_time,created_at,region_rel_expired_id,remark,module,expired_at,latest_check_at,notice_times from region_rel_expireds;
|
|
|
-- pk region_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【region_rels】建视图语句 ==
|
|
|
-- drop view view_region_rels;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_region_rels') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_region_rels;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_region_rels as select region_rel_id as id,region_rel_id,region_id,region_level,operator_id,created_at,deleted_at,updated_at,latest_update_time from region_rels;
|
|
|
-- pk region_rel_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【responsible_salesmans】建视图语句 ==
|
|
|
-- drop view view_responsible_salesmans;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_responsible_salesmans') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_responsible_salesmans;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_responsible_salesmans as select responsible_salesman_id as id,responsible_salesman_id,customer_rel_id,salesman_id,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,customer_id,operator_id from responsible_salesmans;
|
|
|
-- pk responsible_salesman_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【sales_details】建视图语句 ==
|
|
|
-- drop view view_sales_details;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_sales_details') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_sales_details;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_sales_details as select sales_detail_id as id,sales_detail_id,data_from,original_order_number,sale_date,salesman_id,region_id,superior_region_id,sales_method_id,customer_id,product_id,price,amount,is_returned,operator_id,company_id,created_at,updated_at,deleted_at,latest_update_time,address,department,total_price_and_tax from sales_details;
|
|
|
-- pk sales_detail_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【sales_methods】建视图语句 ==
|
|
|
-- drop view view_sales_methods;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_sales_methods') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_sales_methods;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_sales_methods as select created_at,data_from,sales_method_id,updated_at,method_name,operator_id,latest_update_time from sales_methods;
|
|
|
-- pk
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【salesman_rels】建视图语句 ==
|
|
|
-- drop view view_salesman_rels;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_salesman_rels') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_salesman_rels;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_salesman_rels as select salesman_rel_id as id,salesman_rel_id,salesman_level,status,created_at,updated_at,deleted_at,latest_update_time,salesman_id,operator_id from salesman_rels;
|
|
|
-- pk salesman_rel_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【salesmans】建视图语句 ==
|
|
|
-- drop view view_salesmans;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_salesmans') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_salesmans;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_salesmans as select salesman_id as id,salesman_id,salesman_code,salesman_name,data_from,status,phone,company_id,created_at,updated_at,deleted_at,latest_update_time,operator_id,disabled_at from salesmans;
|
|
|
-- pk salesman_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【solution_groups】建视图语句 ==
|
|
|
-- drop view view_solution_groups;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_solution_groups') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_solution_groups;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_solution_groups as select solution_group_id as id,solution_group_id,solution_group_name,created_at,updated_at,deleted_at,operator_id from solution_groups;
|
|
|
-- pk solution_group_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【solutions】建视图语句 ==
|
|
|
-- drop view view_solutions;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_solutions') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_solutions;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_solutions as select solution_id as id,solution_id,database_name,schema_name,solution_group_id,solution_name,latest_update_time,status,created_at,updated_at,deleted_at,compute_business_name,compute_business_id,operator_id,begin_time,end_time from solutions;
|
|
|
-- pk solution_id
|
|
|
-- jsonb operator,compute_items,salesmen
|
|
|
|
|
|
|
|
|
-- == 表【project_costs】建视图语句 ==
|
|
|
-- drop view view_project_costs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_project_costs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_project_costs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_project_costs as select project_cost_id as id,project_cost_id,data_from,created_at,deleted_at,updated_at,product_id,happen_time,money,subject,region_id,salesman_id,customer_id,operator_id,latest_update_time,department from project_costs;
|
|
|
-- pk project_cost_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【region_belongs】建视图语句 ==
|
|
|
-- drop view view_region_belongs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_region_belongs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_region_belongs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_region_belongs as select region_belong_id as id,region_belong_id,begin_time,end_time,status,parent_region_id,region_id,operator_id,created_at,deleted_at,updated_at,latest_update_time from region_belongs;
|
|
|
-- pk region_belong_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【region_categorys】建视图语句 ==
|
|
|
-- drop view view_region_categorys;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_region_categorys') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_region_categorys;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_region_categorys as select region_category_id as id,region_category_id,begin_time,end_time,status,category_type,tag,operator_id,created_at,deleted_at,latest_update_time,updated_at,region_id from region_categorys;
|
|
|
-- pk region_category_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【region_salesmans】建视图语句 ==
|
|
|
-- drop view view_region_salesmans;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_region_salesmans') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_region_salesmans;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_region_salesmans as select region_salesman_id as id,region_salesman_id,region_id,salesman_id,begin_time,created_at,deleted_at,end_time,latest_update_time,updated_at,status,operator_id from region_salesmans;
|
|
|
-- pk region_salesman_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【regions】建视图语句 ==
|
|
|
-- drop view view_regions;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_regions') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_regions;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_regions as select region_id as id,region_id,region_code,region_name,data_from,status,company_id,created_at,updated_at,deleted_at,latest_update_time,disabled_at from regions;
|
|
|
-- pk region_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【superior_responsible_persons】建视图语句 ==
|
|
|
-- drop view view_superior_responsible_persons;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_superior_responsible_persons') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_superior_responsible_persons;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_superior_responsible_persons as select superior_responsible_person_id as id,superior_responsible_person_id,salesman_rel_id,salesman_id,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,superior_salesman_id,operator_id from superior_responsible_persons;
|
|
|
-- pk superior_responsible_person_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【type_tags】建视图语句 ==
|
|
|
-- drop view view_type_tags;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_type_tags') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_type_tags;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_type_tags as select type_tag_id as id,type_tag_id,rel_id,type_tag_module,type_tag_name,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,type_tag_code,operator_id from type_tags;
|
|
|
-- pk type_tag_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【editor_module_confs】建视图语句 ==
|
|
|
-- drop view view_editor_module_confs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_editor_module_confs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_editor_module_confs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_editor_module_confs as select id,name,report_id,is_checked,uri,created_at,updated_at from editor_module_confs;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【editor_user_conf_logs】建视图语句 ==
|
|
|
-- drop view view_editor_user_conf_logs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_editor_user_conf_logs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_editor_user_conf_logs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_editor_user_conf_logs as select id,user_id,user_name,report_id,report_name,module_name,created_at from editor_user_conf_logs;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【product_shares】建视图语句 ==
|
|
|
-- drop view view_product_shares;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_product_shares') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_product_shares;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_product_shares as select product_share_id as id,product_share_id,customer_rel_id,shared_product_id,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,customer_id,salesman_type,salesman_id,salesman_share,operator_id,extra_attribute,group_id from product_shares;
|
|
|
-- pk product_share_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【superior_customers】建视图语句 ==
|
|
|
-- drop view view_superior_customers;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_superior_customers') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_superior_customers;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_superior_customers as select superior_customer_id as id,superior_customer_id,customer_rel_id,customer_id,valid_period_begin,valid_period_end,status,created_at,updated_at,deleted_at,latest_update_time,superior_customer_uid,operator_id from superior_customers;
|
|
|
-- pk superior_customer_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【editor_report_confs】建视图语句 ==
|
|
|
-- drop view view_editor_report_confs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_editor_report_confs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_editor_report_confs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_editor_report_confs as select id,name,platform_id,created_at,updated_at,permission_flag from editor_report_confs;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【areas】建视图语句 ==
|
|
|
-- drop view view_areas;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_areas') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_areas;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_areas as select area_code,city_code,parent_code,level,merger_name,name,short_name,zip_code,full_name,id,pinyin,lng,lat,full_area_code from areas;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【editor_chart_confs】建视图语句 ==
|
|
|
-- drop view view_editor_chart_confs;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_editor_chart_confs') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_editor_chart_confs;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_editor_chart_confs as select id,name,module_id,chart_conf,chart_data_conf,is_checked,is_default,created_at,updated_at,deleted_at from editor_chart_confs;
|
|
|
-- pk
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【editor_user_chart_conf】建视图语句 ==
|
|
|
-- drop view view_editor_user_chart_conf;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_editor_user_chart_conf') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_editor_user_chart_conf;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_editor_user_chart_conf as select editor_user_chart_conf_id as id,editor_user_chart_conf_id,phone,report_id,module_id,module_permissions,chart_id,chart_checked,sort_by,created_at,updated_at,deleted_at,module_checked from editor_user_chart_conf;
|
|
|
-- pk editor_user_chart_conf_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【users】建视图语句 ==
|
|
|
-- drop view view_users;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_users') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_users;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_users as select user_id as id,user_id,user_name,user_account,password,user_avatar,company_id,status,created_at,updated_at,deleted_at from users;
|
|
|
-- pk user_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【offline_expenses】建视图语句 ==
|
|
|
-- drop view view_offline_expenses;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_offline_expenses') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_offline_expenses;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_offline_expenses as select project_cost_id as id,project_cost_id,data_from,created_at,deleted_at,updated_at,product_id,happen_time,money,subject,region_id,salesman_id,customer_id,operator_id,latest_update_time,department from offline_expenses;
|
|
|
-- pk project_cost_id
|
|
|
-- jsonb operator
|
|
|
|
|
|
|
|
|
-- == 表【regular_employee】建视图语句 ==
|
|
|
-- drop view view_regular_employee;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_regular_employee') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_regular_employee;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_regular_employee as select regular_employee_id as id,regular_employee_id,salesman_code,salesman_name,confirmation_date,operator_id,created_at,updated_at,deleted_at,latest_update_time from regular_employee;
|
|
|
-- pk regular_employee_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【employee_relations】建视图语句 ==
|
|
|
-- drop view view_employee_relations;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_employee_relations') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_employee_relations;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_employee_relations as select employee_relations_id as id,employee_relations_id,start_time,end_time,expense_area,expense_operator_code,primary_area_name,secondary_area_name,salesman_name,distribution_proportion,operator_id,created_at,updated_at,deleted_at,latest_update_time from employee_relations;
|
|
|
-- pk employee_relations_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【operate_rules】建视图语句 ==
|
|
|
-- drop view view_operate_rules;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_operate_rules') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_operate_rules;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_operate_rules as select operate_rule_id as id,operate_rule_id,customer_code,product_code,area_code,allocation_proportion,primary_area_name,secondary_area_name,performance_type,opportunity_territory,start_time,end_time,operator_id,created_at,updated_at,deleted_at,latest_update_time from operate_rules;
|
|
|
-- pk operate_rule_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【share_customer_expenses】建视图语句 ==
|
|
|
-- drop view view_share_customer_expenses;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_share_customer_expenses') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_share_customer_expenses;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_share_customer_expenses as select share_customer_expenses_id as id,share_customer_expenses_id,customer_code,primary_area_name,secondary_area_name,expense_type,start_time,end_time,operator_id,created_at,updated_at,deleted_at,latest_update_time from share_customer_expenses;
|
|
|
-- pk share_customer_expenses_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【customer_comparisons】建视图语句 ==
|
|
|
-- drop view view_customer_comparisons;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_customer_comparisons') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_customer_comparisons;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_customer_comparisons as select customer_comparison_id as id,customer_comparison_id,customer_code,summary_area,primary_area_name,secondary_area_name,self_support_or_opportunity,start_time,end_time,operator_id,created_at,updated_at,deleted_at,rebate,latest_update_time from customer_comparisons;
|
|
|
-- pk customer_comparison_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
|
|
-- == 表【regional_ownerships】建视图语句 ==
|
|
|
-- drop view view_regional_ownerships;
|
|
|
DO $$
|
|
|
BEGIN
|
|
|
IF EXISTS (SELECT 1 FROM information_schema.views WHERE table_name = 'view_regional_ownerships') THEN
|
|
|
-- 如果存在就删除视图
|
|
|
DROP VIEW view_regional_ownerships;
|
|
|
RAISE NOTICE '视图已删除';
|
|
|
ELSE
|
|
|
RAISE NOTICE '视图不存在';
|
|
|
END IF;
|
|
|
END $$;
|
|
|
create view view_regional_ownerships as select regional_ownerships_id as id,regional_ownerships_id,start_time,end_time,area,secondary_area_name,salesman_code,salesman_name,is_incremental_commission,is_profit_increase_commission,operator_id,created_at,updated_at,deleted_at,latest_update_time from regional_ownerships;
|
|
|
-- pk regional_ownerships_id
|
|
|
-- jsonb
|
|
|
|
|
|
|
...
|
...
|
|