CREATE TABLE `cities` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;and
CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `city_id` int(11) NOT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `users_ibfk_0` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB;
Anything else and you are fundamentally altering how all this logic works.
Having a system that builds code from a database is backwards to how this is all designed.
It looks like you're new here. If you want to get involved, click one of these buttons!