--liquibase formatted sql

--changeset patrick.thomlinson:orders-ids-to-int
	SET FOREIGN_KEY_CHECKS=0;

	UPDATE `orders` SET `organization_id` = '0', group_id = NULL, location_id = NULL;

	ALTER TABLE `orders` 
		CHANGE COLUMN `organization_id` `organization_id` INT NOT NULL,
		CHANGE COLUMN `group_id` `group_id` INT NULL DEFAULT NULL,
		CHANGE COLUMN `location_id` `location_id` INT NULL DEFAULT NULL;
	
	SET FOREIGN_KEY_CHECKS=1;

--changeset damon.overboe:orders-alter-make-pk-id-only
	SET FOREIGN_KEY_CHECKS=0;

	ALTER TABLE `orders`
	DROP PRIMARY KEY,
	ADD PRIMARY KEY (`id`);

	ALTER TABLE `orders`
	CHANGE COLUMN `sw_number` `sw_number` varchar(45) NULL DEFAULT NULL;

	SET FOREIGN_KEY_CHECKS=1;
