
USE parts;

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

CREATE TABLE IF NOT EXISTS parts.DOG_Command (
	  id_command INT NOT NULL AUTO_INCREMENT PRIMARY KEY
	, id_command_category INT NOT NULL
    , CONSTRAINT FK_DOG_Command_id_command_category
		FOREIGN KEY (id_command_category)
        REFERENCES parts.DOG_Command_Category(id_command_category)
    , name VARCHAR(250) NOT NULL
	, hand_signal_default_description TEXT
    , can_have_button BIT NOT NULL DEFAULT 0
	, notes TEXT
    , active BIT NOT NULL DEFAULT 1
	, created_on DATETIME
    , id_user_created_by INT
    , CONSTRAINT FK_DOG_Command_id_user_created_by
        FOREIGN KEY (id_user_created_by)
        REFERENCES parts.DOG_User(id_user)
	, id_change_set INT
	, CONSTRAINT FK_DOG_Command_id_change_set
		FOREIGN KEY (id_change_set) 
		REFERENCES parts.DOG_Dog_Change_Set(id_change_set)
);
