SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

ALTER TABLE OH_MEDICALDSRSTOCKMOV 
DROP FOREIGN KEY FK_MEDICALDSRSTOCKMOV_WARD;
ALTER TABLE OH_MEDICALDSRSTOCKMOV 
CHANGE COLUMN MMV_WRD_ID_A MMV_WRD_ID_A CHAR(3) NULL DEFAULT NULL;
ALTER TABLE OH_MEDICALDSRSTOCKMOV 
ADD CONSTRAINT FK_MEDICALDSRSTOCKMOV_WARD
  FOREIGN KEY (MMV_WRD_ID_A)
  REFERENCES OH_WARD (WRD_ID_A)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRSTOCKMOVWARD 
DROP FOREIGN KEY FK_MEDICALDSRSTOCKMOVWARD_WARD;
ALTER TABLE OH_MEDICALDSRSTOCKMOVWARD 
CHANGE COLUMN MMVN_WRD_ID_A MMVN_WRD_ID_A CHAR(3) NOT NULL;
ALTER TABLE OH_MEDICALDSRSTOCKMOVWARD 
ADD CONSTRAINT FK_MEDICALDSRSTOCKMOVWARD_WARD
  FOREIGN KEY (MMVN_WRD_ID_A)
  REFERENCES OH_WARD (WRD_ID_A)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRWARD 
DROP FOREIGN KEY FK_MEDICALDSRWARD_WARD;
ALTER TABLE OH_MEDICALDSRWARD 
CHANGE COLUMN MDSRWRD_WRD_ID_A MDSRWRD_WRD_ID_A CHAR(3) NOT NULL;
ALTER TABLE OH_MEDICALDSRWARD 
ADD CONSTRAINT FK_MEDICALDSRWARD_WARD
  FOREIGN KEY (MDSRWRD_WRD_ID_A)
  REFERENCES OH_WARD (WRD_ID_A)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE OH_VISITS 
DROP FOREIGN KEY FK_VISITS_WARD;
ALTER TABLE OH_VISITS 
CHANGE COLUMN VST_WRD_ID_A VST_WRD_ID_A CHAR(3) NOT NULL;
ALTER TABLE OH_VISITS 
ADD CONSTRAINT FK_VISITS_WARD
  FOREIGN KEY (VST_WRD_ID_A)
  REFERENCES OH_WARD (WRD_ID_A)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

ALTER TABLE OH_WARD ALTER WRD_ID_A DROP DEFAULT;