Skip to content

Commit 0bf4e4b

Browse files
committed
Changeup flow setting to allign with code0-tech/tucana#96
1 parent 59be20a commit 0bf4e4b

File tree

8 files changed

+7
-73
lines changed

8 files changed

+7
-73
lines changed

app/models/flow_setting.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
class FlowSetting < ApplicationRecord
44
belongs_to :flow, optional: true
5-
belongs_to :definition, class_name: 'FlowSettingDefinition'
65

76
def to_grpc
87
Tucana::Shared::FlowSetting.new(
9-
definition: definition.to_grpc,
8+
database_id: id,
9+
flow_setting_id: flow_setting_id,
1010
object: Tucana::Shared::Struct.from_ruby(object)
1111
)
1212
end

app/models/flow_setting_definition.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.

db/migrate/20250526124346_create_flows.rb

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

5454
t.references :input_type, null: true, foreign_key: { to_table: :data_types,
55-
on_delete: :restrict }
55+
on_delete: :restrict }
5656
t.references :return_type, null: true, foreign_key: { to_table: :data_types,
57-
on_delete: :restrict }
57+
on_delete: :restrict }
5858

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

@@ -63,17 +63,10 @@ def change
6363

6464
add_reference :data_types, :flows, null: true, foreign_key: { to_table: :flows, on_delete: :restrict }
6565

66-
create_table :flow_setting_definitions do |t|
67-
t.text :identifier, null: false
68-
t.text :key, null: false
69-
70-
t.timestamps_with_timezone
71-
end
72-
7366
create_table :flow_settings do |t|
7467
t.references :flow, null: true, foreign_key: { to_table: :flows, on_delete: :cascade }
7568

76-
t.references :definition, null: false, foreign_key: { to_table: :flow_setting_definitions, on_delete: :cascade }
69+
t.text :flow_setting_id, null: false
7770
t.jsonb :object, null: false
7871

7972
t.timestamps_with_timezone

db/structure.sql

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,10 @@ CREATE SEQUENCE data_types_id_seq
182182

183183
ALTER SEQUENCE data_types_id_seq OWNED BY data_types.id;
184184

185-
CREATE TABLE flow_setting_definitions (
186-
id bigint NOT NULL,
187-
identifier text NOT NULL,
188-
key text NOT NULL,
189-
created_at timestamp with time zone NOT NULL,
190-
updated_at timestamp with time zone NOT NULL
191-
);
192-
193-
CREATE SEQUENCE flow_setting_definitions_id_seq
194-
START WITH 1
195-
INCREMENT BY 1
196-
NO MINVALUE
197-
NO MAXVALUE
198-
CACHE 1;
199-
200-
ALTER SEQUENCE flow_setting_definitions_id_seq OWNED BY flow_setting_definitions.id;
201-
202185
CREATE TABLE flow_settings (
203186
id bigint NOT NULL,
204187
flow_id bigint,
205-
definition_id bigint NOT NULL,
188+
flow_setting_id text NOT NULL,
206189
object jsonb NOT NULL,
207190
created_at timestamp with time zone NOT NULL,
208191
updated_at timestamp with time zone NOT NULL
@@ -862,8 +845,6 @@ ALTER TABLE ONLY data_type_rules ALTER COLUMN id SET DEFAULT nextval('data_type_
862845

863846
ALTER TABLE ONLY data_types ALTER COLUMN id SET DEFAULT nextval('data_types_id_seq'::regclass);
864847

865-
ALTER TABLE ONLY flow_setting_definitions ALTER COLUMN id SET DEFAULT nextval('flow_setting_definitions_id_seq'::regclass);
866-
867848
ALTER TABLE ONLY flow_settings ALTER COLUMN id SET DEFAULT nextval('flow_settings_id_seq'::regclass);
868849

869850
ALTER TABLE ONLY flow_type_settings ALTER COLUMN id SET DEFAULT nextval('flow_type_settings_id_seq'::regclass);
@@ -954,9 +935,6 @@ ALTER TABLE ONLY data_type_rules
954935
ALTER TABLE ONLY data_types
955936
ADD CONSTRAINT data_types_pkey PRIMARY KEY (id);
956937

957-
ALTER TABLE ONLY flow_setting_definitions
958-
ADD CONSTRAINT flow_setting_definitions_pkey PRIMARY KEY (id);
959-
960938
ALTER TABLE ONLY flow_settings
961939
ADD CONSTRAINT flow_settings_pkey PRIMARY KEY (id);
962940

@@ -1107,8 +1085,6 @@ CREATE INDEX index_data_types_on_parent_type_id ON data_types USING btree (paren
11071085

11081086
CREATE UNIQUE INDEX index_data_types_on_runtime_id_and_identifier ON data_types USING btree (runtime_id, identifier);
11091087

1110-
CREATE INDEX index_flow_settings_on_definition_id ON flow_settings USING btree (definition_id);
1111-
11121088
CREATE INDEX index_flow_settings_on_flow_id ON flow_settings USING btree (flow_id);
11131089

11141090
CREATE INDEX index_flow_type_settings_on_data_type_id ON flow_type_settings USING btree (data_type_id);
@@ -1357,9 +1333,6 @@ ALTER TABLE ONLY flows
13571333
ALTER TABLE ONLY node_functions
13581334
ADD CONSTRAINT fk_rails_8953e1d86a FOREIGN KEY (runtime_function_id) REFERENCES runtime_function_definitions(id) ON DELETE RESTRICT;
13591335

1360-
ALTER TABLE ONLY flow_settings
1361-
ADD CONSTRAINT fk_rails_8c9f4f986e FOREIGN KEY (definition_id) REFERENCES flow_setting_definitions(id) ON DELETE CASCADE;
1362-
13631336
ALTER TABLE ONLY data_type_identifiers
13641337
ADD CONSTRAINT fk_rails_8d8385e8ec FOREIGN KEY (runtime_id) REFERENCES runtimes(id) ON DELETE CASCADE;
13651338

spec/factories/flow_setting_definitions.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

spec/factories/flow_settings.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FactoryBot.define do
44
factory :flow_setting do
55
flow
6-
definition factory: %i[flow_setting_definition]
6+
flow_setting_id { 'default' }
77
object { { enabled: true } }
88
end
99
end

spec/models/flow_setting_definition_spec.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

spec/models/flow_setting_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77

88
describe 'associations' do
99
it { is_expected.to belong_to(:flow).optional }
10-
it { is_expected.to belong_to(:definition).class_name('FlowSettingDefinition') }
1110
end
1211
end

0 commit comments

Comments
 (0)