Skip to content

Commit 73d6a42

Browse files
committed
Refactor flow associations to use input_type and return_type instead of input_type_identifier and return_type_identifier to align with grpc implementation of the flow
1 parent 4840d0f commit 73d6a42

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

app/models/flow.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class Flow < ApplicationRecord
44
belongs_to :project, class_name: 'NamespaceProject'
55
belongs_to :flow_type
6-
belongs_to :input_type_identifier, class_name: 'DataTypeIdentifier', optional: true
7-
belongs_to :return_type_identifier, class_name: 'DataTypeIdentifier', optional: true
6+
belongs_to :input_type, class_name: 'DataType', optional: true
7+
belongs_to :return_type, class_name: 'DataType', optional: true
88
belongs_to :starting_node, class_name: 'NodeFunction'
99

1010
has_many :flow_settings
@@ -15,8 +15,8 @@ def to_grpc
1515
project_id: project.id,
1616
flow_type_id: flow_type.identifier,
1717
data_types: [], # TODO
18-
input_type_id: input_type_identifier&.identifier,
19-
return_type_id: return_type_identifier&.identifier,
18+
input_type_id: input_type&.identifier,
19+
return_type_id: return_type&.identifier,
2020
settings: flow_settings.map(&:to_grpc),
2121
starting_node: starting_node.to_grpc
2222
)

db/migrate/20250526124346_create_flows.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def change
5151
on_delete: :cascade }
5252
t.references :flow_type, null: false, foreign_key: { to_table: :flow_types, on_delete: :cascade }
5353

54-
t.references :input_type_identifier, null: true, foreign_key: { to_table: :data_type_identifiers,
54+
t.references :input_type, null: true, foreign_key: { to_table: :data_types,
5555
on_delete: :restrict }
56-
t.references :return_type_identifier, null: true, foreign_key: { to_table: :data_type_identifiers,
56+
t.references :return_type, null: true, foreign_key: { to_table: :data_types,
5757
on_delete: :restrict }
5858

5959
t.references :starting_node, null: false, foreign_key: { to_table: :node_functions, on_delete: :restrict }

db/structure.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ CREATE TABLE flows (
262262
id bigint NOT NULL,
263263
project_id bigint NOT NULL,
264264
flow_type_id bigint NOT NULL,
265-
input_type_identifier_id bigint,
266-
return_type_identifier_id bigint,
265+
input_type_id bigint,
266+
return_type_id bigint,
267267
starting_node_id bigint NOT NULL,
268268
created_at timestamp with time zone NOT NULL,
269269
updated_at timestamp with time zone NOT NULL
@@ -1147,11 +1147,11 @@ CREATE UNIQUE INDEX index_flow_types_on_runtime_id_and_identifier ON flow_types
11471147

11481148
CREATE INDEX index_flows_on_flow_type_id ON flows USING btree (flow_type_id);
11491149

1150-
CREATE INDEX index_flows_on_input_type_identifier_id ON flows USING btree (input_type_identifier_id);
1150+
CREATE INDEX index_flows_on_input_type_id ON flows USING btree (input_type_id);
11511151

11521152
CREATE INDEX index_flows_on_project_id ON flows USING btree (project_id);
11531153

1154-
CREATE INDEX index_flows_on_return_type_identifier_id ON flows USING btree (return_type_identifier_id);
1154+
CREATE INDEX index_flows_on_return_type_id ON flows USING btree (return_type_id);
11551155

11561156
CREATE INDEX index_flows_on_starting_node_id ON flows USING btree (starting_node_id);
11571157

@@ -1285,9 +1285,6 @@ ALTER TABLE ONLY function_definitions
12851285
ALTER TABLE ONLY node_parameters
12861286
ADD CONSTRAINT fk_rails_0ff4fd0049 FOREIGN KEY (runtime_parameter_id) REFERENCES runtime_parameter_definitions(id) ON DELETE CASCADE;
12871287

1288-
ALTER TABLE ONLY flows
1289-
ADD CONSTRAINT fk_rails_10bea7d7dc FOREIGN KEY (return_type_identifier_id) REFERENCES data_type_identifiers(id) ON DELETE RESTRICT;
1290-
12911288
ALTER TABLE ONLY data_types
12921289
ADD CONSTRAINT fk_rails_118c914ed0 FOREIGN KEY (runtime_id) REFERENCES runtimes(id) ON DELETE CASCADE;
12931290

@@ -1309,9 +1306,6 @@ ALTER TABLE ONLY generic_types
13091306
ALTER TABLE ONLY generic_mappers
13101307
ADD CONSTRAINT fk_rails_2adace81b8 FOREIGN KEY (source_id) REFERENCES data_type_identifiers(id) ON DELETE RESTRICT;
13111308

1312-
ALTER TABLE ONLY flows
1313-
ADD CONSTRAINT fk_rails_362b88d836 FOREIGN KEY (input_type_identifier_id) REFERENCES data_type_identifiers(id) ON DELETE RESTRICT;
1314-
13151309
ALTER TABLE ONLY namespace_licenses
13161310
ADD CONSTRAINT fk_rails_38f693332d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
13171311

@@ -1393,6 +1387,9 @@ ALTER TABLE ONLY flow_settings
13931387
ALTER TABLE ONLY data_type_identifiers
13941388
ADD CONSTRAINT fk_rails_8d8385e8ec FOREIGN KEY (runtime_id) REFERENCES runtimes(id) ON DELETE CASCADE;
13951389

1390+
ALTER TABLE ONLY flows
1391+
ADD CONSTRAINT fk_rails_8f97500cd4 FOREIGN KEY (return_type_id) REFERENCES data_types(id) ON DELETE RESTRICT;
1392+
13961393
ALTER TABLE ONLY reference_paths
13971394
ADD CONSTRAINT fk_rails_92e51047ea FOREIGN KEY (reference_value_id) REFERENCES reference_values(id) ON DELETE RESTRICT;
13981395

@@ -1417,6 +1414,9 @@ ALTER TABLE ONLY flows
14171414
ALTER TABLE ONLY reference_values
14181415
ADD CONSTRAINT fk_rails_bb34a5d62c FOREIGN KEY (data_type_identifier_id) REFERENCES data_type_identifiers(id) ON DELETE RESTRICT;
14191416

1417+
ALTER TABLE ONLY flows
1418+
ADD CONSTRAINT fk_rails_bb587eff6a FOREIGN KEY (input_type_id) REFERENCES data_types(id) ON DELETE RESTRICT;
1419+
14201420
ALTER TABLE ONLY function_generic_mappers
14211421
ADD CONSTRAINT fk_rails_be1833ba72 FOREIGN KEY (source_id) REFERENCES data_type_identifiers(id) ON DELETE RESTRICT;
14221422

spec/models/flow_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
it { is_expected.to belong_to(:project).class_name('NamespaceProject') }
1010
it { is_expected.to belong_to(:flow_type) }
1111
it { is_expected.to belong_to(:starting_node).class_name('NodeFunction') }
12+
it { is_expected.to belong_to(:input_type).class_name('DataType').optional }
13+
it { is_expected.to belong_to(:return_type).class_name('DataType').optional }
1214
end
1315
end

0 commit comments

Comments
 (0)