Sha256: 5d512712046c71aea2c5a969c0237716b2b546773f92a994ed0a2b65b55ae339

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

Sequel.migration do
  transaction
  up do
    run 'ALTER TABLE `tasks` ADD CONSTRAINT `task_master_id` FOREIGN KEY (`master_id`) REFERENCES `tasks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;'
    run 'ALTER TABLE `tasks` ADD CONSTRAINT `task_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `tasks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;'

    run 'ALTER TABLE `task_logs` CHANGE `node_id` `node_id` INT(11)  UNSIGNED  NULL;'

    run 'ALTER TABLE `task_logs` ADD CONSTRAINT `task_logs_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;'
    run 'ALTER TABLE `task_logs` ADD CONSTRAINT `task_logs_node_id` FOREIGN KEY (`node_id`) REFERENCES `nodes` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;'
  end

  down do
    run 'ALTER TABLE `task_logs` DROP FOREIGN KEY `task_logs_node_id`;'
    run 'ALTER TABLE `task_logs` DROP FOREIGN KEY `task_logs_task_id`;'

    run 'ALTER TABLE `task_logs` CHANGE `node_id` `node_id` INT(11)  UNSIGNED NOT NULL;'

    run 'ALTER TABLE `tasks` DROP FOREIGN KEY `task_parent_id`;'
    run 'ALTER TABLE `tasks` DROP FOREIGN KEY `task_master_id`;'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
legion-data-0.1.1 lib/legion/data/migrations/016_tasks_foreign_keys.rb
legion-data-0.1.0 lib/legion/data/migrations/016_tasks_foreign_keys.rb