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

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

alter table hrsa_sub_table add table_type int
GO

alter table hrsa_sub_table add constraint df_table_type_7b1e7561 default 0 for table_type
GO

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

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

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

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

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

alter table hrsa_salary_stats_dim alter column dim_type nvarchar(30)
GO

alter table hrsa_salary_stats_report alter column income_category_setting nvarchar(1000)
GO

alter table hrsa_salary_stats_report add remark nvarchar(100)
GO

alter table hrsa_salary_stats_report add second_dimension nvarchar(100)
GO

alter table hrsa_salary_stats_report add sort_index nvarchar(100)
GO

alter table hrsa_salary_stats_report add sort_type nvarchar(100)
GO

alter table hrsa_salary_stats_dim add label_id int
GO