--ABS-62304 / ABS-85835

--------- CREDITCARDFIXEDPAYDATES --------------

CREATE SEQUENCE SEQ_CREDITCARDFIXEDPAYDATES
START WITH 1
INCREMENT BY 1;

CREATE TABLE CREDITCARDFIXEDPAYDATES (CREDITCARDFIXEDPAYDATES_ID NUMBER NOT NULL,
                                      PLANT_ID NUMBER NOT NULL,
                                      PAYMENTDATE DATE NOT NULL,
                                      SYSTEMUSER_ID NUMBER NOT NULL,
                                      TIMESTAMP DATE NOT NULL);
                                      
ALTER TABLE CREDITCARDFIXEDPAYDATES ADD CONSTRAINT PKCREDITCARDFIXEDPAYDATES PRIMARY KEY(CREDITCARDFIXEDPAYDATES_ID);

CREATE UNIQUE INDEX XAK1CREDITCARDFIXEDPAYDATES ON CREDITCARDFIXEDPAYDATES(PLANT_ID ASC, PAYMENTDATE ASC);
CREATE INDEX XIF1CREDITCARDFIXEDPAYDATES ON CREDITCARDFIXEDPAYDATES(PLANT_ID ASC);

ALTER TABLE CREDITCARDFIXEDPAYDATES ADD CONSTRAINT FK_CCFIXEDPAYDATES_PLANT_ID FOREIGN KEY(PLANT_ID)
REFERENCES PLANT(PLANT_ID);


------------------ CREDITCARDCHARGESCHEDULE --------------
COMMENT ON COLUMN CREDITCARDCHARGESCHEDULE.TYPE
IS '1 = Day of Month
2 = Last day of Month
3 = Day of week within month
4 = Day of week
5 = Day after billing day
6 = Fixed scheme';
ALTER TABLE CREDITCARDCHARGESCHEDULE DROP CONSTRAINT CHK_CCCHARGESCHEDULE_TYPE;
ALTER TABLE CREDITCARDCHARGESCHEDULE ADD CONSTRAINT CHK_CCCHARGESCHEDULE_TYPE CHECK(TYPE IN(1,2,3,4,5,6));
