CREATE TABLE IF NOT EXISTS vn.`budgetState` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(45) NOT NULL, `description` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `budgetState_UN` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ALTER TABLE vn.budget ADD IF NOT EXISTS budgetStateFk varchar(45) NULL; ALTER TABLE vn.budget ADD CONSTRAINT budgetStateFk FOREIGN KEY IF NOT EXISTS (budgetStateFk) REFERENCES vn.budgetState(code) ON DELETE RESTRICT ON UPDATE CASCADE;