ALTER TABLE account.sambaConfig ADD adUser VARCHAR(255) DEFAULT NULL NULL COMMENT 'Active directory user';
ALTER TABLE account.sambaConfig ADD adPassword varchar(255) DEFAULT NULL NULL COMMENT 'Active directory password';
ALTER TABLE account.sambaConfig ADD userDn varchar(255) DEFAULT NULL NULL COMMENT 'The base DN for users';
ALTER TABLE account.sambaConfig DROP COLUMN uidBase;
ALTER TABLE account.sambaConfig CHANGE sshPass sshPassword varchar(255) DEFAULT NULL NULL COMMENT 'The SSH password';

ALTER TABLE account.ldapConfig DROP COLUMN `filter`;
ALTER TABLE account.ldapConfig CHANGE baseDn userDn varchar(255) DEFAULT NULL NULL COMMENT 'The base DN to do the query';
ALTER TABLE account.ldapConfig CHANGE host server varchar(255) NOT NULL COMMENT 'The hostname of LDAP server';
ALTER TABLE account.ldapConfig MODIFY COLUMN password varchar(255) NOT NULL COMMENT 'The LDAP password';

-- Updated

ALTER TABLE account.sambaConfig DROP COLUMN sshUser;
ALTER TABLE account.sambaConfig DROP COLUMN sshPassword;
ALTER TABLE account.sambaConfig CHANGE host adController varchar(255) DEFAULT NULL NULL COMMENT 'The hosname of domain controller';
ALTER TABLE account.sambaConfig MODIFY COLUMN adController varchar(255) DEFAULT NULL NULL COMMENT 'The hosname of domain controller';

ALTER TABLE account.sambaConfig DROP COLUMN userDn;
ALTER TABLE account.sambaConfig ADD adDomain varchar(255) NOT NULL AFTER id;
ALTER TABLE account.sambaConfig ADD verifyCert TINYINT UNSIGNED NOT NULL DEFAULT TRUE AFTER adPassword;
ALTER TABLE account.sambaConfig MODIFY COLUMN adController varchar(255) NOT NULL COMMENT 'The hosname of domain controller';

ALTER TABLE account.user
	ADD COLUMN `realm` varchar(512) CHARACTER SET utf8 DEFAULT NULL AFTER id,
	ADD COLUMN `emailVerified` tinyint(1) DEFAULT NULL AFTER email,
	ADD COLUMN `verificationToken` varchar(512) DEFAULT NULL AFTER emailVerified;
  
DROP TABLE salix.user;

CREATE OR REPLACE VIEW salix.User
	AS SELECT id, realm, name AS username, bcryptPassword AS password, email, emailVerified, verificationToken
		FROM account.user;
	
ALTER TABLE account.`user`
	MODIFY COLUMN bcryptPassword varchar(512) DEFAULT NULL NULL;
