Skip to content

Commit 27a77a9

Browse files
committed
Make constraints to node functions deferrable
1 parent 3f3c4b4 commit 27a77a9

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
class MakeNodeFunctionConstraintsDeferrable < Code0::ZeroTrack::Database::Migration[1.0]
4+
def change
5+
remove_foreign_key :reference_values,
6+
:node_functions,
7+
on_delete: :restrict
8+
9+
add_foreign_key :reference_values,
10+
:node_functions,
11+
deferrable: :deferred
12+
13+
remove_foreign_key :node_functions,
14+
:node_functions,
15+
column: :next_node_id,
16+
on_delete: :restrict
17+
18+
add_foreign_key :node_functions,
19+
:node_functions,
20+
column: :next_node_id,
21+
deferrable: :deferred
22+
end
23+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
501fc65ab83b207de468a27d7e65c82b75fcf7f55def5678bd84e666b16dbd7f

db/structure.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ ALTER TABLE ONLY node_functions
13431343
ADD CONSTRAINT fk_rails_8615bd0635 FOREIGN KEY (flow_id) REFERENCES flows(id) ON DELETE CASCADE;
13441344

13451345
ALTER TABLE ONLY reference_values
1346-
ADD CONSTRAINT fk_rails_8b9d8f68cc FOREIGN KEY (node_function_id) REFERENCES node_functions(id) ON DELETE RESTRICT;
1346+
ADD CONSTRAINT fk_rails_8b9d8f68cc FOREIGN KEY (node_function_id) REFERENCES node_functions(id) DEFERRABLE INITIALLY DEFERRED;
13471347

13481348
ALTER TABLE ONLY data_type_identifiers
13491349
ADD CONSTRAINT fk_rails_8d8385e8ec FOREIGN KEY (runtime_id) REFERENCES runtimes(id) ON DELETE CASCADE;
@@ -1415,4 +1415,4 @@ ALTER TABLE ONLY flow_type_settings
14151415
ADD CONSTRAINT fk_rails_f6af7d8edf FOREIGN KEY (flow_type_id) REFERENCES flow_types(id) ON DELETE CASCADE;
14161416

14171417
ALTER TABLE ONLY node_functions
1418-
ADD CONSTRAINT fk_rails_fbc91a3407 FOREIGN KEY (next_node_id) REFERENCES node_functions(id) ON DELETE RESTRICT;
1418+
ADD CONSTRAINT fk_rails_fbc91a3407 FOREIGN KEY (next_node_id) REFERENCES node_functions(id) DEFERRABLE INITIALLY DEFERRED;

0 commit comments

Comments
 (0)