use `akura`;

--
-- Table structure for table `USER_LOGIN`
--
ALTER TABLE `USER_LOGIN` 
MODIFY `GENERATED_PASSWORD` SMALLINT(6) NOT NULL DEFAULT '0';

--
-- Table structure for table `GRADE_SUBJECT`
--
ALTER TABLE `GRADE_SUBJECT` 
ADD COLUMN `MAXIMUM_MARKS` INT(11) NOT NULL DEFAULT 100  ;

--
-- Table structure for table `STUDENT_TEMPORARY_LEAVE`
--
CREATE TABLE `STUDENT_TEMPORARY_LEAVE` (
  `STUDENT_TEMPORARY_LEAVE_ID` int(11) NOT NULL AUTO_INCREMENT,
  `REASON` varchar(100) NOT NULL,
  `TO_DATE` date NOT NULL,
  `FROM_DATE` date NOT NULL,
  `COMPLETE_CLEARANCE` tinyint(4) DEFAULT '0',
  `NO_OF_DAYS` int(11) DEFAULT NULL,
  `STUDENT_ID` int(11) NOT NULL,
  `ACTIVATE_DATE` date DEFAULT NULL,
  `MODIFIED_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`STUDENT_TEMPORARY_LEAVE_ID`),
  KEY `fk_STUDENT_TEMPORARY_LEAVE_1` (`STUDENT_ID`),
  CONSTRAINT `fk_STUDENT_TEMPORARY_LEAVE_1` FOREIGN KEY (`STUDENT_ID`) REFERENCES `STUDENT` (`STUDENT_ID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `STUDENT_SUSPEND_DETAILS`
--
CREATE TABLE `STUDENT_SUSPEND_DETAILS` (
  `SUSPEND_STUDENT_ID` int(11) NOT NULL AUTO_INCREMENT,
  `STUDENT_ID` int(11) NOT NULL,
  `FROM_DATE` date NOT NULL,
  `TO_DATE` date NOT NULL,
  `DISCIPLINARY_ACTION_ID` int(11) NOT NULL,
  `DESCRIPTION` varchar(150) DEFAULT NULL,
  `MODIFIED_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `NO_OF_DAYS` int(11) NOT NULL,
  `ACTIVATED_DATE` date DEFAULT NULL,
  `CURTAILED_OR_EXTENDED_REASON` varchar(150) DEFAULT NULL, 
  PRIMARY KEY (`SUSPEND_STUDENT_ID`),
  KEY `fk_STUDENT_ID` (`STUDENT_ID`),
  KEY `fk_DISCIPLINARY_ACTION_ID` (`DISCIPLINARY_ACTION_ID`),
  CONSTRAINT `fk_DISCIPLINARY_ACTION_ID` FOREIGN KEY (`DISCIPLINARY_ACTION_ID`) REFERENCES `STUDENT_DISCIPLINE` (`STUDENT_DISCIPLINE_ID`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `fk_STUDENT_ID` FOREIGN KEY (`STUDENT_ID`) REFERENCES `STUDENT` (`STUDENT_ID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `PAST_STUDENT`
--
CREATE TABLE `PAST_STUDENT` (
  `PAST_STUDENT_ID` int(11) NOT NULL AUTO_INCREMENT,
  `STUDENT_ID` int(11) NOT NULL,
  `DEPARTURE_DATE` date NOT NULL,
  `REASON` varchar(250) NOT NULL,
  `COMPLETE_CLEARANCE` TINYINT(4) DEFAULT 0,
  `ADMISSION_DATE` DATE NOT NULL, 
  `MODIFIED_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`PAST_STUDENT_ID`),
  KEY `fk_PAST_STUDENT_STUDENT1` (`STUDENT_ID`),
  CONSTRAINT `fk_PAST_STUDENT_STUDENT1` FOREIGN KEY (`STUDENT_ID`) REFERENCES `STUDENT` (`STUDENT_ID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `STUDENT`
--
ALTER TABLE `STUDENT` 
ADD COLUMN `DEPARTURE_DATE` DATE DEFAULT NULL ;


--
-- Table structure for table `STUDENT_PARENT`
--
ALTER TABLE `STUDENT_PARENT` 
ADD COLUMN `DELETED` TINYINT(4) DEFAULT 0 ;

--
-- Table structure for table `DONATION`
--
ALTER TABLE `DONATION` 
CHANGE COLUMN `AMOUNT` `AMOUNT` VARCHAR(45) NULL DEFAULT NULL  ;


--
-- Table structure for table `STUDENT_LEAVE`
--
ALTER TABLE `STUDENT_LEAVE` 
ADD COLUMN `CHECK_AUTOGENERATED` tinyint(4) NOT NULL DEFAULT '0' ;


--
-- Table structure for table `STAFF`
--
UPDATE `STAFF` 
SET `GENDER` = 'M' 
WHERE `GENDER` != 'M' AND `GENDER` != 'F';

--
-- Table structure for table `SPECIAL_EVENTS`
--
ALTER TABLE `SPECIAL_EVENTS` 
CHANGE COLUMN `DESCRIPTION` `DESCRIPTION` VARCHAR(400) NOT NULL  ;

--
-- Table structure for table `STAFF_LEAVE_TYPE`
--
ALTER TABLE `STAFF_LEAVE_TYPE` 
ADD COLUMN `GENDER` CHAR(1) DEFAULT 'A' ;

--
-- Table structure for table `ASSIGNMENT`
--
ALTER TABLE `ASSIGNMENT` 
CHANGE COLUMN `DESCRIPTION` `DESCRIPTION` VARCHAR(250) NULL DEFAULT NULL  ;

--
-- Table structure for table `SCHOOL`
--
ALTER TABLE `SCHOOL` CHANGE COLUMN `VICE_PRINCIPAL` `VICE_PRINCIPAL` INT(11) NULL DEFAULT NULL ;

--
-- Table structure for table `STUDENT_SUB_TERM_MARK`
--
ALTER TABLE `STUDENT_SUB_TERM_MARK` 
DROP FOREIGN KEY `fk_STUDENT_SUB_TERM_MARK_STUDENT_TERM_MARK1` ;


ALTER TABLE `STUDENT_SUB_TERM_MARK` 

  ADD CONSTRAINT `fk_STUDENT_SUB_TERM_MARK_STUDENT_TERM_MARK1`

  FOREIGN KEY (`STUDENT_TERM_MARKS_ID` )

  REFERENCES `STUDENT_TERM_MARK` (`STUDENT_TERM_MARKS_ID` )

  ON DELETE CASCADE

  ON UPDATE CASCADE;






