ALTER TABLE CLASSIFICATION ADD (
  DIVIDE_DURATION VARCHAR2(1) DEFAULT 'Y' NOT NULL
)
/
ALTER TABLE CLASSIFICATION ADD CONSTRAINT CK_CLASSIFICATION_DIVIDE_DURAT CHECK (DIVIDE_DURATION IN ('Y','N'))
/
CREATE TABLE BUDGET_ITEM (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'A'  NOT NULL, 
  NAME VARCHAR2(255) NOT NULL, 
  VALUE DOUBLE PRECISION DEFAULT NULL NULL, 
  UNIT_MEASURE VARCHAR2(255) NOT NULL,
  CONSTRAINT PK_BUDGET_ITEM PRIMARY KEY(ID)
)
/
CREATE SEQUENCE SEQ_BUDGET_ITEM START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE CLASSIFICATION_BUDGET_ITEM (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  CLASSIFICATION NUMBER(10) NOT NULL, 
  BUDGET_ITEM NUMBER(10) NOT NULL,
  CONSTRAINT PK_CLASSIFICATION_BUDGET_ITEM PRIMARY KEY(ID)
)
/
ALTER TABLE CLASSIFICATION_BUDGET_ITEM ADD CONSTRAINT FK_CLAS_BUD_ITEM_BUD_ITEM FOREIGN KEY (CLASSIFICATION) REFERENCES CLASSIFICATION (ID)
/
ALTER TABLE CLASSIFICATION_BUDGET_ITEM ADD CONSTRAINT FK_CLAS_BUD_ITEM_CLAS FOREIGN KEY (BUDGET_ITEM) REFERENCES BUDGET_ITEM (ID)
/
CREATE SEQUENCE SEQ_CLASSIFICATION_BUDGET_ITEM START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE BUDGET (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  SITUATION VARCHAR2(1) DEFAULT 'C' NOT NULL, 
  TASK NUMBER(10) NOT NULL, 
  DISCOUNT_PERCENT DOUBLE PRECISION DEFAULT NULL NULL, 
  DISCOUNT_VALUE DOUBLE PRECISION DEFAULT NULL NULL,
  CONSTRAINT PK_BUDGET PRIMARY KEY(ID)
)
/
ALTER TABLE BUDGET ADD CONSTRAINT FK_BUDGET_TASK FOREIGN KEY (TASK) REFERENCES TASK (ID)
/
CREATE SEQUENCE SEQ_BUDGET START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE BUDGET_ITEM_BUDGET (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  BUDGET_ITEM NUMBER(10) NOT NULL, 
  BUDGET NUMBER(10) NOT NULL, 
  QUANTITY DOUBLE PRECISION DEFAULT NULL NULL, 
  ITEM_VALUE DOUBLE PRECISION DEFAULT NULL NULL, 
  UNIT_MEASURE VARCHAR2(255) DEFAULT NULL NULL,
  CONSTRAINT PK_BUDGET_ITEMS_BUDGET PRIMARY KEY(ID)
)
/
ALTER TABLE BUDGET_ITEM_BUDGET ADD CONSTRAINT FK_BUD_IT_BUD_BUD_IT FOREIGN KEY (BUDGET_ITEM) REFERENCES BUDGET_ITEM (ID)
/
ALTER TABLE BUDGET_ITEM_BUDGET ADD CONSTRAINT FK_BUD_ITEM_BUD_BUD FOREIGN KEY (BUDGET) REFERENCES BUDGET (ID)
/
CREATE SEQUENCE SEQ_BUDGET_ITEM_BUDGET START WITH 1 MINVALUE 1 INCREMENT BY 1
/
ALTER TABLE PRODUCT_SERVER ADD (
  EXEC_SCRIPTS_AUTOMATIC VARCHAR2(255) DEFAULT 'N' NOT NULL
)
/
ALTER TABLE PRODUCT_SERVER ADD CONSTRAINT CKC_EXEC_SCRIPTS_AUTOMATIC CHECK (EXEC_SCRIPTS_AUTOMATIC IN ('Y', 'N'))
