Sequel.migration do transaction up do run 'ALTER TABLE `chains` ADD CONSTRAINT `chains_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;' run 'ALTER TABLE `chains` ADD CONSTRAINT `chains_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `datacenters` ADD CONSTRAINT `datacenters_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `datacenters` ADD CONSTRAINT `datacenters_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `environments` ADD CONSTRAINT `environments_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `environments` ADD CONSTRAINT `environments_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `functions` ADD CONSTRAINT `functions_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `functions` ADD CONSTRAINT `functions_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `namespaces` ADD CONSTRAINT `namespaces_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `namespaces` ADD CONSTRAINT `namespaces_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' run 'ALTER TABLE `relationships` ADD CONSTRAINT `relationships_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;' run 'ALTER TABLE `relationships` ADD CONSTRAINT `relationships_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;' end down do run 'ALTER TABLE `relationships` DROP FOREIGN KEY `relationships_group_owner`;' run 'ALTER TABLE `relationships` DROP FOREIGN KEY `relationships_user_owner`;' run 'ALTER TABLE `namespaces` DROP FOREIGN KEY `namespaces_group_owner`;' run 'ALTER TABLE `namespaces` DROP FOREIGN KEY `namespaces_user_owner`;' run 'ALTER TABLE `functions` DROP FOREIGN KEY `functions_group_owner`;' run 'ALTER TABLE `functions` DROP FOREIGN KEY `functions_user_owner`;' run 'ALTER TABLE `environments` DROP FOREIGN KEY `environments_group_owner`;' run 'ALTER TABLE `environments` DROP FOREIGN KEY `environments_user_owner`;' run 'ALTER TABLE `datacenters` DROP FOREIGN KEY `datacenters_group_owner`;' run 'ALTER TABLE `datacenters` DROP FOREIGN KEY `datacenters_user_owner`;' run 'ALTER TABLE `chains` DROP FOREIGN KEY `chains_group_owner`;' run 'ALTER TABLE `chains` DROP FOREIGN KEY `chains_user_owner`;' end end