create table hrsa_sub_table
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    sub_table_name varchar(100) not null ,
    dimension varchar(20) not null ,
    start_month varchar(10) ,
    end_month varchar(10) ,
    pay_org_string varchar(500) ,
    pay_agency_string varchar(500) ,
    sub_company_string varchar(500) ,
    depart_string varchar(500) ,
    grade_string varchar(500) ,
    position_string varchar(500) ,
    status_string varchar(500) ,
    employee_type varchar(500) ,
    employee_string varchar(500) ,
    payment_type_string varchar(100) 
)
;

create table hrsa_sub_table_item
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    table_id bigint not null ,
    item_name varchar(50) not null ,
    item_value varchar(500) not null ,
    index_value int not null ,
    total_rule varchar(500) ,
    count_rule varchar(500) ,
    unit_type int default 2 
)
;

alter table hrsa_sub_table add table_type int
;

alter table hrsa_sub_table ALTER table_type TYPE int 
;

alter table  hrsa_sub_table ALTER COLUMN table_type set DEFAULT 0
; 



create table hrsa_salary_stats_dim
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    dim_name varchar(100) ,
    dim_type varchar(20) ,
    remark varchar(500) ,
    setting varchar(2000) ,
    is_default int ,
    dim_code varchar(50) 
)
;

create table hrsa_salary_stats_report
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    report_name varchar(100) ,
    dimension varchar(1000) ,
    tax_agent_setting varchar(1000) ,
    income_category_setting varchar(20) ,
    sub_company_setting varchar(1000) ,
    depart_setting varchar(1000) ,
    grade_setting varchar(1000) ,
    position_setting varchar(1000) ,
    status_setting varchar(1000) ,
    employee_setting varchar(1000) ,
    hiredate_setting varchar(1000) ,
    leavedate_setting varchar(1000) ,
    salary_start_month timestamp ,
    salary_end_month timestamp 
)
;

create table hrsa_salary_statistics_item
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    item_name varchar(50) ,
    item_value varchar(1000) ,
    count_rule varchar(500) ,
    sum_rule varchar(500) ,
    avg_rule varchar(500) ,
    max_rule varchar(500) ,
    min_rule varchar(500) ,
    median_rule varchar(500) ,
    index_value int ,
    unit_type int ,
    stat_report_id bigint 
)
;

create table hrsa_charts_setting
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    table_id bigint not null ,
    charts_type int not null ,
    item_values varchar(500) ,
    item_col_value varchar(50) not null ,
    dimension_range int not null ,
    item_sort_value varchar(500) ,
    item_col_sort_value varchar(50) ,
    sort_type int ,
    sort_num int 
)
;

create table hrsa_salary_echarts_setting
(
    id bigint primary key ,
    create_time timestamp ,
    update_time timestamp ,
    creator bigint ,
    delete_type int default 0 ,
    tenant_key varchar(10) ,
    report_id bigint not null ,
    charts_type int not null ,
    item_values varchar(500) ,
    item_col_value varchar(50) not null ,
    dimension_range int not null ,
    item_sort_value varchar(500) ,
    item_col_sort_value varchar(50) ,
    sort_type int ,
    sort_num int 
)
;

alter table hrsa_salary_stats_dim alter dim_type TYPE varchar(30)
;

alter table hrsa_salary_stats_report alter income_category_setting TYPE varchar(1000)
;

alter table hrsa_salary_stats_report add remark varchar(100)
;

alter table hrsa_salary_stats_report add second_dimension varchar(100)
;

alter table hrsa_salary_stats_report add sort_index varchar(100)
;

alter table hrsa_salary_stats_report add sort_type varchar(100)
;

alter table hrsa_salary_stats_dim add label_id int
;