
USE partsltd_prod;

SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning 
FROM INFORMATION_SCHEMA.TABLES 
WHERE 
        TABLE_SCHEMA = 'partsltd_prod' 
    AND TABLE_NAME = 'PH_Calc_User_Temp'
;

CREATE TABLE IF NOT EXISTS partsltd_prod.PH_Calc_User_Temp (
	  guid BINARY(36) NOT NULL
	, id_user INT
	, id_permission_required INT NOT NULL
	, CONSTRAINT FK_PH_Calc_User_Temp_id_permission_required
		FOREIGN KEY (id_permission_required)
		REFERENCES partsltd_prod.PH_Permission (id_permission)
	, priority_access_level_required INT NOT NULL
	, is_super_user BIT
	, priority_access_level_user INT
	, has_access BIT
);