
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 = 'PH_Contact_Form'
;

CREATE TABLE IF NOT EXISTS parts.PH_Contact_Form (
	  id_contact_form INT NOT NULL AUTO_INCREMENT PRIMARY KEY
	, email VARCHAR(255) NOT NULL
	, name_contact VARCHAR(255) NOT NULL
	, name_company VARCHAR(255) NOT NULL
	, message TEXT NOT NULL
    , receive_marketing_communications BIT NOT NULL DEFAULT 0
	, active BIT NOT NULL DEFAULT 1
	, created_on DATETIME
    , id_user_created_by INT
    , CONSTRAINT FK_PH_Contact_Form_id_user_created_by
        FOREIGN KEY (id_user_created_by)
        REFERENCES parts.DOG_User(id_user)
	, id_change_set INT
	, CONSTRAINT FK_PH_Contact_Form_id_change_set
		FOREIGN KEY (id_change_set) 
		REFERENCES parts.PH_Contact_Form_Change_Set(id_change_set)
);
