CREATE TABLE `userpersonaldetailcustomdata` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `userId` INT NULL,
  `isActive` TINYINT NULL DEFAULT '1',
  `isDelete` TINYINT NULL DEFAULT '0',
  `createdDate` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `modifiedDate` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` INT NULL DEFAULT NULL,
  `modifiedBy` VARCHAR(45) NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_userpersonaldetailcustomdata_user_idx` (`userId` ASC) ,
  CONSTRAINT `fk_userpersonaldetailcustomdata_user`
    FOREIGN KEY (`userId`)
    REFERENCES `users` (`id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT);

    CREATE TABLE `customfields` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NULL DEFAULT NULL,
  `displayName` VARCHAR(100) NULL DEFAULT NULL,
  `mappedTableName` VARCHAR(100) NULL DEFAULT NULL,
  `description` LONGTEXT NULL DEFAULT NULL,
  `valueTypeId` INT NULL DEFAULT NULL,
  `isRequired` TINYINT NULL DEFAULT NULL,
  `allowInSearch` TINYINT NULL DEFAULT NULL,
  `allowInFilter` TINYINT NULL DEFAULT NULL,
  `allowIncompleteProfile` TINYINT NULL DEFAULT NULL,
  `allowInPreferences` TINYINT NULL DEFAULT NULL,
  `defaultValue` LONGTEXT NULL DEFAULT NULL,
  `valueList` LONGTEXT NULL DEFAULT NULL,
  `isActive` TINYINT NULL DEFAULT '1',
  `isDelete` TINYINT NULL DEFAULT '0',
  `createdDate` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `modifiedDate` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` INT NULL DEFAULT NULL,
  `modifiedBy` INT NULL DEFAULT NULL,
  PRIMARY KEY (`id`));

  INSERT INTO `flaggroup` (`id`, `flagGroupName`, `detail`, `displayOrder`) VALUES ('14', 'Modules', 'Modules', '8');
  INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`) VALUES ('45', '14', '7', 'isEnableCustomFields', 'Enable CustomFields', '1', '1');
  ALTER TABLE `valuetypes` 
ADD COLUMN `isShowInCustomField` TINYINT NULL DEFAULT NULL AFTER `modifiedBy`;
UPDATE `valuetypes` SET `isShowInCustomField` = '1' WHERE (`id` = '1');
UPDATE `valuetypes` SET `isShowInCustomField` = '1' WHERE (`id` = '2');
UPDATE `valuetypes` SET `isShowInCustomField` = '1' WHERE (`id` = '3');
UPDATE `valuetypes` SET `isShowInCustomField` = '1' WHERE (`id` = '10');
ALTER TABLE `customfields` 
CHANGE COLUMN `mappedTableName` `mappedFieldName` VARCHAR(100) NULL DEFAULT NULL ;
ALTER TABLE `customfields` 
CHANGE COLUMN `isRequired` `isRequired` TINYINT NULL DEFAULT '0' ,
CHANGE COLUMN `allowInSearch` `allowInSearch` TINYINT NULL DEFAULT '0' ,
CHANGE COLUMN `allowInFilter` `allowInFilter` TINYINT NULL DEFAULT '0' ,
CHANGE COLUMN `allowIncompleteProfile` `allowIncompleteProfile` TINYINT NULL DEFAULT '0' ,
CHANGE COLUMN `allowInPreferences` `allowInPreferences` TINYINT NULL DEFAULT '0' ;
ALTER TABLE `valuetypes` 
ADD COLUMN `isUseForFilter` TINYINT NULL DEFAULT NULL AFTER `isShowInCustomField`;
ALTER TABLE `valuetypes` 
ADD COLUMN `remark` VARCHAR(45) NULL DEFAULT NULL AFTER `isUseForFilter`;
UPDATE `valuetypes` SET `isUseForFilter` = '0' WHERE (`id` = '1');
UPDATE `valuetypes` SET `isUseForFilter` = '0' WHERE (`id` = '2');
UPDATE `valuetypes` SET `isUseForFilter` = '1' WHERE (`id` = '3');
UPDATE `valuetypes` SET `isUseForFilter` = '1' WHERE (`id` = '10');
ALTER TABLE `valuetypes` 
CHANGE COLUMN `remark` `remark` VARCHAR(200) NULL DEFAULT NULL ;
UPDATE `valuetypes` SET `remark` = 'If you enable this flag, the application may cause malware crash' WHERE (`id` = '1');
UPDATE `valuetypes` SET `remark` = 'If you enable this flag, the application may cause malware crash' WHERE (`id` = '2');
ALTER TABLE `userauthdata` 
CHANGE COLUMN `oAuthAccessToken` `oAuthAccessToken` LONGTEXT NULL DEFAULT NULL ,
CHANGE COLUMN `description` `description` LONGTEXT NULL DEFAULT NULL ;
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `isActive`, `isDelete`) VALUES ('46', '1', '7', 'isVerifyCustomerProfile', 'Verify Customer Profile', '1', '1', '1', '0');
ALTER TABLE `users` 
ADD COLUMN `isVerifyProfilePic` TINYINT NULL AFTER `isReceiveNotification`;
UPDATE `systemflags` SET `name` = 'isUserProfilePicApprove', `displayName` = 'User ProfilePic Approved', `description` = 'User Profile Pic Approved from admin' WHERE (`id` = '46');
ALTER TABLE `customfields` 
ADD COLUMN `completeprofilesectioname` VARCHAR(100) NULL DEFAULT NULL AFTER `valueList`;
ALTER TABLE `weight` 
CHANGE COLUMN `name` `name` INT NOT NULL ;
ALTER TABLE `userproposals` 
ADD COLUMN `hascancelled` TINYINT NULL DEFAULT '0' AFTER `modifiedBy`;

ALTER TABLE `customfields` 
ADD COLUMN `textLength` INT NULL DEFAULT NULL AFTER `isRequired`;

ALTER TABLE `userpersonaldetail` 
ADD COLUMN `memberid` VARCHAR(45) NULL AFTER `modifiedBy`,
ADD UNIQUE INDEX `memberid_UNIQUE` (`memberid` ASC) ;

ALTER TABLE `feedback` 
CHANGE COLUMN `isActive` `isActive` TINYINT NULL DEFAULT '0' ;

INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('51', '1', '4', 'copyrightText', 'CopyRight Text', '(©) Copyright 2024 Matrimony. All Rights Reserved.', '(©) Copyright 2024 Matrimony. All Rights Reserved.', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');

INSERT INTO `flaggroup` (`id`, `flagGroupName`, `detail`, `parentFlagGroupId`, `displayOrder`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('15', 'App Links', 'App Links', '1', '3', '1', '0', '2023-12-13 15:25:14', '2023-12-13 15:25:14', '1', '1');

INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('49', '15', '1', 'appstore', 'App Store', 'https://www.apple.com/in/app-store/', 'https://www.apple.com/in/app-store/', '1', '1', '0', '2023-12-13 15:28:26', '2023-12-13 15:28:26', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('50', '15', '1', 'playstore', 'Play Store', 'https://www.apple.com/in/app-store/', 'https://www.apple.com/in/app-store/', '1', '1', '0', '2023-12-13 15:28:26', '2023-12-13 15:28:26', '1', '1');

INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('52', '1', '4', 'facebookLink', 'Facebook Link', 'https://www.facebook.com/', 'https://www.facebook.com/', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('53', '1', '4', 'instagramLink', 'Instagram Link', 'https://www.instagram.com/', 'https://www.instagram.com/', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('54', '1', '4', 'twitterLink', 'Twitter Link', 'https://x.com/?lang=en', 'https://x.com/?lang=en', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('55', '1', '4', 'linkedinLink', 'Linkedin Link', 'https://in.linkedin.com/', 'https://in.linkedin.com/', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('56', '1', '4', 'threadsLink', 'Threads Link', 'https://www.threads.net/login/', 'https://www.threads.net/login/', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');

INSERT INTO `flaggroup` (`id`, `flagGroupName`, `detail`, `parentFlagGroupId`, `displayOrder`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('16', 'Social Links', 'Social Links', '1', '3', '1', '0', '2023-12-13 15:25:14', '2023-12-13 15:25:14', '1', '1');

UPDATE `systemflags` SET `flagGroupId` = '1', `valueTypeId` = '4' WHERE (`id` = '51');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '52');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '53');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '54');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '55');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '56');

UPDATE `systemflags` SET `value` = 'https://www.threads.net/login/' WHERE (`id` = '56');
UPDATE `systemflags` SET `value` = 'https://in.linkedin.com/' WHERE (`id` = '55');
UPDATE `systemflags` SET `value` = 'https://x.com/?lang=en' WHERE (`id` = '54');
UPDATE `systemflags` SET `value` = 'https://www.instagram.com/' WHERE (`id` = '53');
UPDATE `systemflags` SET `value` = 'https://www.facebook.com/' WHERE (`id` = '52');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1', `value` = '(©) Copyright 2024 Matrimony. All Rights Reserved.' WHERE (`id` = '51');

UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1', `value` = '(©) Copyright 2024 Matrimony. All Rights Reserved.' WHERE (`id` = '51');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '52');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1', `value` = 'https://www.instagram.com/' WHERE (`id` = '53');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '54');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1', `value` = 'https://in.linkedin.com/' WHERE (`id` = '55');
UPDATE `systemflags` SET `flagGroupId` = '16', `valueTypeId` = '1' WHERE (`id` = '56');

INSERT INTO `flaggroup` (`id`, `flagGroupName`, `detail`, `parentFlagGroupId`, `displayOrder`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('17', 'App Name', 'App Name', '1', '3', '1', '0', '2023-12-13 15:25:14', '2023-12-13 15:25:14', '1', '1');

INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('57', '16', '1', 'appName', 'App Name', 'Matrimony', 'Matrimony', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');

INSERT INTO `flaggroup` (`id`, `flagGroupName`, `detail`, `parentFlagGroupId`, `displayOrder`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('18', 'Contact Us', 'Contact Us', '1', '3', '1', '0', '2023-12-13 15:25:14', '2023-12-13 15:25:14', '1', '1');

INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('58', '18', '1', 'Address', 'Address', '47 W 13th St, New York, NY 10011, USA', '47 W 13th St, New York, NY 10011, USA', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('59', '18', '1', 'Email', 'Email', 'support@matrimony.com', 'support@matrimony.com', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');
INSERT INTO `systemflags` (`id`, `flagGroupId`, `valueTypeId`, `name`, `displayName`, `value`, `defaultValue`, `autoRender`, `isActive`, `isDelete`, `createdDate`, `modifiedDate`, `createdBy`, `modifiedBy`) VALUES ('60', '18', '1', 'Phone Number', 'Phone Number', '9898989898', '9898989898', '1', '1', '0', '2023-12-27 12:06:37', '2023-12-27 12:06:37', '1', '1');

UPDATE `systemflags` SET `name` = 'address' WHERE (`id` = '58');
UPDATE `systemflags` SET `name` = 'email' WHERE (`id` = '59');
UPDATE `systemflags` SET `name` = 'phoneNumber' WHERE (`id` = '60');