Skip to content

Commit 3a70731

Browse files
committed
Changeup flow setting to allign with code0-tech/tucana#96
1 parent 73d6a42 commit 3a70731

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
@@ -879,8 +862,6 @@ ALTER TABLE ONLY data_type_rules ALTER COLUMN id SET DEFAULT nextval('data_type_
879862

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

882-
ALTER TABLE ONLY flow_setting_definitions ALTER COLUMN id SET DEFAULT nextval('flow_setting_definitions_id_seq'::regclass);
883-
884865
ALTER TABLE ONLY flow_settings ALTER COLUMN id SET DEFAULT nextval('flow_settings_id_seq'::regclass);
885866

886867
ALTER TABLE ONLY flow_type_settings ALTER COLUMN id SET DEFAULT nextval('flow_type_settings_id_seq'::regclass);
@@ -973,9 +954,6 @@ ALTER TABLE ONLY data_type_rules
973954
ALTER TABLE ONLY data_types
974955
ADD CONSTRAINT data_types_pkey PRIMARY KEY (id);
975956

976-
ALTER TABLE ONLY flow_setting_definitions
977-
ADD CONSTRAINT flow_setting_definitions_pkey PRIMARY KEY (id);
978-
979957
ALTER TABLE ONLY flow_settings
980958
ADD CONSTRAINT flow_settings_pkey PRIMARY KEY (id);
981959

@@ -1131,8 +1109,6 @@ CREATE INDEX index_data_types_on_parent_type_id ON data_types USING btree (paren
11311109

11321110
CREATE UNIQUE INDEX index_data_types_on_runtime_id_and_identifier ON data_types USING btree (runtime_id, identifier);
11331111

1134-
CREATE INDEX index_flow_settings_on_definition_id ON flow_settings USING btree (definition_id);
1135-
11361112
CREATE INDEX index_flow_settings_on_flow_id ON flow_settings USING btree (flow_id);
11371113

11381114
CREATE INDEX index_flow_type_settings_on_data_type_id ON flow_type_settings USING btree (data_type_id);
@@ -1381,9 +1357,6 @@ ALTER TABLE ONLY flows
13811357
ALTER TABLE ONLY node_functions
13821358
ADD CONSTRAINT fk_rails_8953e1d86a FOREIGN KEY (runtime_function_id) REFERENCES runtime_function_definitions(id) ON DELETE RESTRICT;
13831359

1384-
ALTER TABLE ONLY flow_settings
1385-
ADD CONSTRAINT fk_rails_8c9f4f986e FOREIGN KEY (definition_id) REFERENCES flow_setting_definitions(id) ON DELETE CASCADE;
1386-
13871360
ALTER TABLE ONLY data_type_identifiers
13881361
ADD CONSTRAINT fk_rails_8d8385e8ec FOREIGN KEY (runtime_id) REFERENCES runtimes(id) ON DELETE CASCADE;
13891362

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)