alter table DT870 add PORTFOLIO_PICTURE raw(16);

create table PORTFOLIO_CTG (
    "UUID" raw(16),
    "COST_TYPE_GROUP_ID" varchar2(20 char),
    "PORTFOLIO_ID" varchar2(18 char),
    "OS_CREATED_ON" date,
    "OS_MODIFIED_ON" date,
    "OS_RWDU" number(5,0),
    "OS_CREATED_BY" varchar2(20 char),
    "OS_MODIFIED_BY" varchar2(20 char),
    "OS_OWN_LIC" varchar2(4 char),
    "OS_OPC" varchar2(8 char),
    "OS_OWNER" number(5,0),
    "OS_GROUP" number(5,0),
    "OS_ANY" number(5,0),
    "COST_TYPE_GROUP_ACTIVE" number(5,0)
);

alter table PORTFOLIO_CTG add constraint PID096DT096 primary key ("COST_TYPE_GROUP_ID", "PORTFOLIO_ID");

create index IDX_PORTFOLIO_CTGID280 on PORTFOLIO_CTG ("COST_TYPE_GROUP_ID");

create index IDX_PORTFOLIO_CTGID870 on PORTFOLIO_CTG ("PORTFOLIO_ID");

alter table PORTFOLIO_CTG MODIFY ("UUID" DEFAULT SYS_GUID());

alter table PORTFOLIO_CTG
    add constraint DT096UUID_NOT_NULL check("UUID" is not null);

alter table PORTFOLIO_CTG
    add constraint DT096COST_TYPE_GROUP_ID_NOT check("COST_TYPE_GROUP_ID" is not null);

alter table PORTFOLIO_CTG
    add constraint DT096PORTFOLIO_ID_NOT_NULL check("PORTFOLIO_ID" is not null);

alter table PORTFOLIO_CTG MODIFY ("OS_CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PORTFOLIO_CTG MODIFY ("OS_MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PORTFOLIO_CTG MODIFY ("OS_RWDU" DEFAULT 0);

alter table PORTFOLIO_CTG MODIFY ("OS_RWDU" DEFAULT 0);

alter table PORTFOLIO_CTG MODIFY ("OS_OWNER" DEFAULT 0);

alter table PORTFOLIO_CTG MODIFY ("OS_GROUP" DEFAULT 0);

alter table PORTFOLIO_CTG MODIFY ("OS_ANY" DEFAULT 0);

alter table PORTFOLIO_CTG MODIFY ("COST_TYPE_GROUP_ACTIVE" DEFAULT 0);

create table PF_REPORT_CTG (
        "UUID" raw(16),
        "COST_TYPE_GROUP_ID" varchar2(20 char),
        "STATUSREPORT_ID" varchar2(10 char),
        "PORTFOLIO_ID" varchar2(18 char),
        "OS_CREATED_ON" date,
        "OS_MODIFIED_ON" date,
        "OS_RWDU" number(5,0),
        "OS_CREATED_BY" varchar2(20 char),
        "OS_MODIFIED_BY" varchar2(20 char),
        "OS_OWN_LIC" varchar2(4 char),
        "OS_OPC" varchar2(8 char),
        "OS_OWNER" number(5,0),
        "OS_GROUP" number(5,0),
        "OS_ANY" number(5,0),
        "COST_TYPE_GROUP_ACTIVE" number(5,0)
    );
alter table PF_REPORT_CTG add constraint PID097DT097 primary key ("COST_TYPE_GROUP_ID", "STATUSREPORT_ID", "PORTFOLIO_ID");

create index IDX_PF_REPORT_CTGID280 on PF_REPORT_CTG ("COST_TYPE_GROUP_ID");

create index IDX_PF_REPORT_CTGID090 on PF_REPORT_CTG ("STATUSREPORT_ID", "PORTFOLIO_ID");

alter table PF_REPORT_CTG
    add constraint UUID_UNIQUE_097  unique ("UUID")
    deferrable;

alter table PF_REPORT_CTG MODIFY ("UUID" DEFAULT SYS_GUID());

alter table PF_REPORT_CTG
    add constraint DT097UUID_NOT_NULL check("UUID" is not null);

alter table PF_REPORT_CTG
    add constraint DT097COST_TYPE_GROUP_ID_NOT check("COST_TYPE_GROUP_ID" is not null);

alter table PF_REPORT_CTG
    add constraint DT097STATUSREPORT_ID_NOT_NULL check("STATUSREPORT_ID" is not null);

alter table PF_REPORT_CTG
    add constraint DT097PORTFOLIO_ID_NOT_NULL check("PORTFOLIO_ID" is not null);

alter table PF_REPORT_CTG MODIFY ("OS_CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PF_REPORT_CTG MODIFY ("OS_MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PF_REPORT_CTG MODIFY ("OS_RWDU" DEFAULT 0);

alter table PF_REPORT_CTG MODIFY ("OS_OWNER" DEFAULT 0);

alter table PF_REPORT_CTG MODIFY ("OS_GROUP" DEFAULT 0);

alter table PF_REPORT_CTG MODIFY ("OS_ANY" DEFAULT 0);

alter table PF_REPORT_CTG MODIFY ("COST_TYPE_GROUP_ACTIVE" DEFAULT 0);

create table USERPROJECTPORTFOLIO (
    "UUID" raw(16),
    "PR_ID" varchar2(18 char),
    "PORTFOLIO_ID" varchar2(18 char),
    "USER_ID" varchar2(20 char),
    "OS_CREATED_ON" date,
    "OS_MODIFIED_ON" date,
    "OS_RWDU" number(5,0),
    "OS_CREATED_BY" varchar2(20 char),
    "OS_MODIFIED_BY" varchar2(20 char),
    "OS_LICENSE" varchar2(4 char),
    "OS_OPC" varchar2(8 char),
    "OS_OWNER" number(5,0),
    "OS_GROUP" number(5,0),
    "OS_ANY" number(5,0)
);

alter table USERPROJECTPORTFOLIO add constraint PID534DT534 primary key ("PR_ID", "PORTFOLIO_ID", "USER_ID");

create index IDX_USERPROJECTPORTFOLIOID858 on USERPROJECTPORTFOLIO ("PR_ID", "PORTFOLIO_ID");

create index IDX_USERPROJECTPORTFOLIOID511 on USERPROJECTPORTFOLIO ("USER_ID");

alter table USERPROJECTPORTFOLIO MODIFY ("UUID" DEFAULT SYS_GUID());

alter table USERPROJECTPORTFOLIO
    add constraint DT534UUID_NOT_NULL check("UUID" is not null);

alter table USERPROJECTPORTFOLIO
    add constraint DT534PR_ID_NOT_NULL check("PR_ID" is not null);

alter table USERPROJECTPORTFOLIO
    add constraint DT534PORTFOLIO_ID_NOT_NULL check("PORTFOLIO_ID" is not null);

alter table USERPROJECTPORTFOLIO MODIFY ("OS_CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table USERPROJECTPORTFOLIO MODIFY ("OS_MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table USERPROJECTPORTFOLIO MODIFY ("OS_RWDU" DEFAULT 0);

alter table USERPROJECTPORTFOLIO MODIFY ("OS_OWNER" DEFAULT 0);

alter table USERPROJECTPORTFOLIO MODIFY ("OS_GROUP" DEFAULT 0);

alter table USERPROJECTPORTFOLIO MODIFY ("OS_ANY" DEFAULT 0);

alter table DT858 add MANAGER_COMMENT clob;

alter table DT093 add MANAGER_COMMENT clob;

create table PICTURE (
    "UUID" raw(16),
    "OS_CREATED_ON" date,
    "OS_MODIFIED_ON" date,
    "OS_RWDU" number(5,0),
    "OS_CREATED_BY" varchar2(20 char),
    "OS_MODIFIED_BY" varchar2(20 char),
    "OS_OWN_LIC" varchar2(4 char),
    "OS_OPC" varchar2(8 char),
    "OS_OWNER" number(5,0),
    "OS_GROUP" number(5,0),
    "OS_ANY" number(5,0),
    "NAME" number(10,0),
    "PICTURE" number(10,0),
    "PICTURE_TYPE" number(5,0),
    "DEFAULT_PICTURE" number(5,0)
);

alter table PICTURE add constraint PID098DT098 primary key ("UUID");

create index IDX_ITEXT_DT098NAME on PICTURE ("NAME");

alter table PICTURE MODIFY ("UUID" DEFAULT SYS_GUID());

alter table PICTURE
    add constraint DT098UUID_NOT_NULL check("UUID" is not null);

alter table PICTURE MODIFY ("OS_CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PICTURE MODIFY ("OS_MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));

alter table PICTURE MODIFY ("OS_RWDU" DEFAULT 0);

alter table PICTURE MODIFY ("OS_OWNER" DEFAULT 0);

alter table PICTURE MODIFY ("OS_GROUP" DEFAULT 0);

alter table PICTURE MODIFY ("OS_ANY" DEFAULT 0);

alter table PICTURE MODIFY ("PICTURE" DEFAULT 0);

alter table PICTURE MODIFY ("PICTURE_TYPE" DEFAULT 0);

alter table PICTURE MODIFY ("DEFAULT_PICTURE" DEFAULT 0);
