/* Alter table in target */
UPDATE `class_schedule` SET dayOfWeek=dayOfWeek+1;
UPDATE `mailsms` SET messageDate='';
UPDATE `settings` SET fieldValue='purple-dark' where fieldName='layoutColor';
UPDATE `users` SET defTheme='purple-dark';

INSERT INTO `settings` ( `fieldName`, `fieldValue`) VALUES
('gTrackId', ''),
('loginPageStyle', 'c'),
('registerPageStyle', 'c'),
('forgetPwdPageStyle', 'c'),
('pullAppClosed', '600'),
('pullAppActive', '3'),
('pullAppMessagesActive', '2'),
('timezone', 'Africa/Cairo'),
('gcalendar', 'gregorian'),
('studentsSort', 'fullName DESC'),
('teachersSort', 'id + 0 ASC'),
('parentsSort', 'fullName ASC'),
('favicon', 'e'),
('paypalEnabled', '1'),
('2coEnabled', '1'),
('twocheckoutsid', ''),
('twocheckoutHash', ''),
('payumoneyEnabled', '1'),
('payumoneyKey', ''),
('payumoneySalt', ''),
('authPageImage', '1'),
('authPageColor', '#c0c0c0');


ALTER TABLE `class_schedule`
	ADD COLUMN `teacherId` int(250)   NOT NULL after `dayOfWeek` ,
	CHANGE `startTime` `startTime` varchar(20)  COLLATE utf8_general_ci NOT NULL after `teacherId` ;

/* Alter table in target */
ALTER TABLE `exams_list`
	ADD COLUMN `examEndDate` int(250)   NOT NULL after `examDate` ,
	CHANGE `examClasses` `examClasses` text  COLLATE utf8_general_ci NOT NULL after `examEndDate` ,
	ADD COLUMN `examSchedule` text  COLLATE utf8_general_ci NOT NULL after `examAcYear` ;

/* Alter table in target */
ALTER TABLE `expenses`
	ADD COLUMN `expenseCategory` int(250)   NOT NULL after `expenseAmount` ,
	CHANGE `expenseImage` `expenseImage` varchar(250)  COLLATE utf8_general_ci NOT NULL after `expenseCategory` ;

/* Create table in target */
CREATE TABLE `expenses_cat`(
	`id` int(250) NOT NULL  auto_increment ,
	`cat_title` varchar(250) COLLATE utf8_general_ci NOT NULL  ,
	`cat_desc` text COLLATE utf8_general_ci NULL  ,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8' COLLATE='utf8_general_ci';

TRUNCATE TABLE `fee_allocation`;

/* Alter table in target */
ALTER TABLE `fee_allocation`
	ADD COLUMN `feeTitle` varchar(250)  COLLATE utf8_general_ci NOT NULL after `id` ,
	ADD COLUMN `feeGroup` int(250)   NOT NULL after `feeTitle` ,
	ADD COLUMN `feeType` int(250)   NOT NULL after `feeGroup` ,
	ADD COLUMN `feeTypeNextTS` int(250)   NOT NULL after `feeType` ,
	ADD COLUMN `feeFor` varchar(250)  COLLATE utf8_general_ci NOT NULL after `feeTypeNextTS` ,
	ADD COLUMN `feeForInfo` text  COLLATE utf8_general_ci NOT NULL after `feeFor` ,
	DROP COLUMN `allocationTitle` ,
	DROP COLUMN `allocationType` ,
	DROP COLUMN `allocationId` ,
	DROP COLUMN `allocationValues` ,
	DROP COLUMN `allocationWhen` ,
	DROP COLUMN `allocationDate` ,
	DROP COLUMN `allocationRec` ,
	DROP COLUMN `isProcessed` ;

/* Create table in target */
CREATE TABLE `fee_group`(
	`id` int(250) NOT NULL  auto_increment ,
	`group_title` varchar(250) COLLATE utf8_general_ci NOT NULL  ,
	`invoice_prefix` varchar(250) COLLATE utf8_general_ci NOT NULL  ,
	`invoice_count` int(250) NOT NULL  DEFAULT 0 ,
	`group_description` text COLLATE utf8_general_ci NULL  ,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8' COLLATE='utf8_general_ci';

TRUNCATE TABLE `fee_type`;
/* Alter table in target */
ALTER TABLE `fee_type`
	ADD COLUMN `feeCode` varchar(250)  COLLATE utf8_general_ci NULL after `feeTitle` ,
	ADD COLUMN `feeDescription` text  COLLATE utf8_general_ci NULL after `feeCode` ,
	ADD COLUMN `feeGroup` int(250)   NOT NULL after `feeDescription` ,
	ADD COLUMN `feeAmount` float   NOT NULL after `feeGroup` ,
	ADD COLUMN `feeSchType` varchar(250)  COLLATE utf8_general_ci NOT NULL after `feeAmount` ,
	ADD COLUMN `feeSchDetails` text  COLLATE utf8_general_ci NOT NULL after `feeSchType` ,
	DROP COLUMN `feeDefault` ,
	DROP COLUMN `feeNotes` ;

/* Alter table in target */
ALTER TABLE `mailsms_templates`
	CHANGE `templateMail` `templateMail` text  COLLATE utf8_general_ci NULL after `templateTitle` ,
	CHANGE `templateSMS` `templateSMS` text  COLLATE utf8_general_ci NULL after `templateMail` ,
	CHANGE `templateVars` `templateVars` text  COLLATE utf8_general_ci NULL after `templateSMS` ;

/* Alter table in target */
ALTER TABLE `payments`
	ADD COLUMN `paymentRows` text  COLLATE utf8_general_ci NOT NULL after `paymentStudent` ,
	CHANGE `paymentAmount` `paymentAmount` float   NOT NULL after `paymentRows` ,
	ADD COLUMN `paidAmount` float   NOT NULL DEFAULT 0 after `paymentAmount` ,
	CHANGE `paymentStatus` `paymentStatus` int(1)   NOT NULL after `paidAmount` ,
	CHANGE `paymentDate` `paymentDate` int(250)   NOT NULL after `paymentStatus` ,
	ADD COLUMN `dueDate` int(250)   NOT NULL after `paymentDate` ,
	CHANGE `paymentUniqid` `paymentUniqid` varchar(250)  COLLATE utf8_general_ci NULL after `dueDate` ,
	ADD COLUMN `paidMethod` varchar(250)  COLLATE utf8_general_ci NULL after `paymentSuccessDetails` ,
	ADD COLUMN `paidTime` int(250)   NULL after `paidMethod` ;

/* Create table in target */
CREATE TABLE `paymentsCollection`(
	`id` int(250) NOT NULL  auto_increment ,
	`invoiceId` int(250) NOT NULL  ,
	`collectionAmount` float NOT NULL  ,
	`collectionDate` int(250) NOT NULL  ,
	`collectionMethod` varchar(250) COLLATE utf8_general_ci NOT NULL  ,
	`collectionNote` text COLLATE utf8_general_ci NOT NULL  ,
	`collectedBy` int(250) NOT NULL  ,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8' COLLATE='utf8_general_ci';


/* Alter table in target */
ALTER TABLE `users`
	ADD COLUMN `comVia` text  COLLATE utf8_general_ci NOT NULL after `defTheme` ,
	ADD COLUMN `updated_at` date   NOT NULL after `comVia` ,
	CHANGE `customPermissionsType` `customPermissionsType` varchar(10)  COLLATE utf8_general_ci NULL after `updated_at` ;
