CREATE TABLE `Warehouse` (
  `id` INT(10) UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  `addressBookId` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `FK1_warehouse_addressBook_id` (`addressBookId`),
  CONSTRAINT `FK1_warehouse_addressBook_id` FOREIGN KEY (`addressBookId`) REFERENCES `AddressBook` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

CREATE TABLE `WarehouseShelf` (
  `id` INT(10) UNSIGNED NOT NULL,
  `warehouseId` INT(10) UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  `location` VARCHAR(50) NULL DEFAULT NULL,
  `description` VARCHAR(50) NULL DEFAULT NULL,
  `capacity` TINYINT(4) NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX `FK1_warehouseId_id` (`warehouseId`),
  CONSTRAINT `FK1_warehouseId_id` FOREIGN KEY (`warehouseId`) REFERENCES `Warehouse` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
  COLLATE='utf8_general_ci'
  ENGINE=InnoDB
;

CREATE TABLE `WarehouseShelfPosition` (
  `id`               INT(10) UNSIGNED NOT NULL,
  `warehouseShelfId` INT(10) UNSIGNED NOT NULL,
  `name`             VARCHAR(50)      NOT NULL,
  `content`          VARCHAR(50)      NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `FK1_warehouse_shelf_id` (`warehouseShelfId`),
  CONSTRAINT `FK1_warehouse_shelf_id` FOREIGN KEY (`warehouseShelfId`) REFERENCES `WarehouseShelf` (`warehouseId`)
    ON UPDATE NO ACTION
    ON DELETE NO ACTION
)
  COLLATE = 'utf8_general_ci'
  ENGINE = InnoDB;

ALTER TABLE `OrderLine`
  ADD COLUMN `warehouseShelfPositionId` INT(10) UNSIGNED NULL DEFAULT NULL
  AFTER `orderLineFriendPaymentDate`;

ALTER TABLE `OrderLine`
  ADD CONSTRAINT `fk_OrderLine_WarehoiseShelfPositionId` FOREIGN KEY (`warehouseShelfPositionId`) REFERENCES `WarehouseShelfPosition` (`id`)
  ON UPDATE NO ACTION
  ON DELETE NO ACTION;

ALTER TABLE `Carrier`
  ADD COLUMN `implementation` VARCHAR(55) NULL DEFAULT null AFTER `prenotationTimeLimit`;

ALTER TABLE `Order`
  ADD COLUMN `shipmentNote` VARCHAR(255) NULL AFTER `note`;