Skip to content

Commit

Permalink
REDUCED diesel (3 tables down from 6)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelMarks committed Aug 31, 2024
1 parent 906be29 commit 392dcf7
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 183 deletions.
1 change: 1 addition & 0 deletions src/lib/diesel_schemas/custom_to_fro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 0 additions & 8 deletions src/lib/diesel_schemas/down.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
DROP TABLE flow_info;

DROP TABLE flow_states;

DROP TABLE modify_configs;

DROP TABLE config_sections;

DROP TABLE tasks;

DROP TABLE steps;
Expand Down
110 changes: 25 additions & 85 deletions src/lib/diesel_schemas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,124 +3,64 @@ pub mod custom_to_fro;
use diesel::table;

table! {
// FlowInfo to store various flow-related information
flow_info (id) {
id -> Integer,
config -> Text, // Assuming Config can be serialized into a JSON-like text format
task -> Text,
env_info -> Text, // Assuming EnvInfo can be stored as JSON-like text
disable_workspace -> Bool,
disable_on_error -> Bool,
allow_private -> Bool,
skip_init_end_tasks -> Bool,
skip_tasks_pattern -> Nullable<Text>,
cli_arguments -> Nullable<Text>, // Optional vector serialized to JSON/text
}
}

table! {
// Stores the state of a flow
flow_states (id) {
id -> Integer,
time_summary -> Jsonb,
forced_plugin -> Nullable<Text>,
}
}

table! {
// ModifyConfig for modifying core tasks
modify_configs (id) {
id -> Integer,
private -> Nullable<Bool>,
namespace -> Nullable<Text>,
}
}

table! {
// ConfigSection, the main configuration store
config_sections (id) {
id -> Integer,
skip_core_tasks -> Nullable<Bool>,
modify_core_tasks -> Nullable<Text>, // Assuming ModifyConfig is serialized to JSON-like format
init_task -> Nullable<Text>,
end_task -> Nullable<Text>,
on_error_task -> Nullable<Text>,
legacy_migration_task -> Nullable<Text>,
additional_profiles -> Nullable<Text>, // Assuming Vec<String> is serialized to JSON-like format
min_version -> Nullable<Text>,
default_to_workspace -> Nullable<Bool>,
skip_git_env_info -> Nullable<Bool>,
skip_rust_env_info -> Nullable<Bool>,
skip_crate_env_info -> Nullable<Bool>,
reduce_output -> Nullable<Bool>,
time_summary -> Nullable<Bool>,
load_cargo_aliases -> Nullable<Bool>,
main_project_member -> Nullable<Text>,
load_script -> Nullable<Text>, // Assuming ScriptValue can be serialized to JSON-like format
linux_load_script -> Nullable<Text>,
windows_load_script -> Nullable<Text>,
mac_load_script -> Nullable<Text>,
unstable_features -> Nullable<Text>, // Assuming IndexSet<UnstableFeature> can be serialized to JSON-like format
}
}

table! {
// Task, stores a single task's configuration
// Task table stores individual task configurations
tasks (id) {
id -> Integer,
clear -> Nullable<Bool>,
description -> Nullable<Text>,
category -> Nullable<Text>,
disabled -> Nullable<Bool>,
private -> Nullable<Bool>,
deprecated -> Nullable<Text>, // Assuming DeprecationInfo serialized to text
deprecated -> Nullable<Jsonb>, // Assuming DeprecationInfo is serialized to JSONB
extend -> Nullable<Text>,
workspace -> Nullable<Bool>,
plugin -> Nullable<Text>,
watch -> Nullable<Text>, // Assuming TaskWatchOptions serialized to text
condition -> Nullable<Text>, // Assuming TaskCondition serialized to text
condition_script -> Nullable<Text>,
condition_script_runner_args -> Nullable<Text>,
watch -> Nullable<Jsonb>, // Assuming TaskWatchOptions is serialized to JSONB
condition -> Nullable<Jsonb>, // Assuming TaskCondition is serialized to JSONB
condition_script -> Nullable<Jsonb>, // Assuming ConditionScriptValue is serialized to JSONB
condition_script_runner_args -> Nullable<Jsonb>, // Assuming Vec<String> is serialized to JSONB
ignore_errors -> Nullable<Bool>,
force -> Nullable<Bool>,
env_files -> Nullable<Text>, // Assuming Vec<EnvFile> serialized to text
env -> Nullable<Text>, // Assuming IndexMap<String, EnvValue> serialized to text
env_files -> Nullable<Jsonb>, // Assuming Vec<EnvFile> is serialized to JSONB
env -> Nullable<Jsonb>, // Assuming IndexMap<String, EnvValue> is serialized to JSONB
cwd -> Nullable<Text>,
alias -> Nullable<Text>,
linux_alias -> Nullable<Text>,
windows_alias -> Nullable<Text>,
mac_alias -> Nullable<Text>,
install_crate -> Nullable<Text>, // Assuming InstallCrate serialized to text
install_crate_args -> Nullable<Text>,
install_script -> Nullable<Text>, // Assuming ScriptValue serialized to text
install_crate -> Nullable<Jsonb>, // Assuming InstallCrate is serialized to JSONB
install_crate_args -> Nullable<Jsonb>, // Assuming Vec<String> is serialized to JSONB
install_script -> Nullable<Jsonb>, // Assuming ScriptValue is serialized to JSONB
command -> Nullable<Text>,
args -> Nullable<Text>,
script -> Nullable<Text>, // Assuming ScriptValue serialized to text
args -> Nullable<Jsonb>, // Assuming Vec<String> is serialized to JSONB
script -> Nullable<Jsonb>, // Assuming ScriptValue is serialized to JSONB
script_runner -> Nullable<Text>,
script_runner_args -> Nullable<Text>,
script_runner_args -> Nullable<Jsonb>, // Assuming Vec<String> is serialized to JSONB
script_extension -> Nullable<Text>,
run_task -> Nullable<Text>, // Assuming RunTaskInfo serialized to text
dependencies -> Nullable<Text>, // Assuming Vec<DependencyIdentifier> serialized to text
toolchain -> Nullable<Text>,
linux -> Nullable<Text>, // Assuming PlatformOverrideTask serialized to text
windows -> Nullable<Text>,
mac -> Nullable<Text>,
run_task -> Nullable<Jsonb>, // Assuming RunTaskInfo is serialized to JSONB
dependencies -> Nullable<Jsonb>, // Assuming Vec<DependencyIdentifier> is serialized to JSONB
toolchain -> Nullable<Jsonb>, // Assuming ToolchainSpecifier is serialized to JSONB
linux -> Nullable<Jsonb>, // Assuming PlatformOverrideTask is serialized to JSONB
windows -> Nullable<Jsonb>,
mac -> Nullable<Jsonb>,
}
}

table! {
// Step table stores execution steps
steps (id) {
id -> Integer,
name -> Text,
config -> Jsonb, // Assuming Task serialized to text
config -> Jsonb, // Assuming Task struct is serialized to JSONB
}
}

table! {
// ExecutionPlan table stores a full execution plan
execution_plans (id) {
id -> Integer,
steps -> Jsonb, // Assuming Vec<Step> serialized to JSON/text
steps_to_run -> Jsonb, // Assuming std::ops::Range<usize> serialized to JSON/text
steps -> Jsonb, // Assuming Vec<Step> is serialized to JSONB
steps_to_run -> Jsonb, // Assuming std::ops::Range<usize> is serialized to JSONB
name -> Text,
}
}
103 changes: 24 additions & 79 deletions src/lib/diesel_schemas/up.sql
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
CREATE TABLE flow_info
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
config TEXT NOT NULL,
task TEXT NOT NULL,
env_info TEXT NOT NULL,
disable_workspace BOOLEAN NOT NULL,
disable_on_error BOOLEAN NOT NULL,
allow_private BOOLEAN NOT NULL,
skip_init_end_tasks BOOLEAN NOT NULL,
skip_tasks_pattern TEXT,
cli_arguments TEXT
);

CREATE TABLE flow_states
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
time_summary TEXT NOT NULL,
forced_plugin TEXT
);

CREATE TABLE modify_configs
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
private BOOLEAN,
namespace TEXT
);

CREATE TABLE config_sections
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
skip_core_tasks BOOLEAN,
modify_core_tasks TEXT,
init_task TEXT,
end_task TEXT,
on_error_task TEXT,
legacy_migration_task TEXT,
additional_profiles TEXT,
min_version TEXT,
default_to_workspace BOOLEAN,
skip_git_env_info BOOLEAN,
skip_rust_env_info BOOLEAN,
skip_crate_env_info BOOLEAN,
reduce_output BOOLEAN,
time_summary BOOLEAN,
load_cargo_aliases BOOLEAN,
main_project_member TEXT,
load_script TEXT,
linux_load_script TEXT,
windows_load_script TEXT,
mac_load_script TEXT,
unstable_features TEXT
);

CREATE TABLE tasks
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
Expand All @@ -60,52 +6,51 @@ CREATE TABLE tasks
category TEXT,
disabled BOOLEAN,
private BOOLEAN,
deprecated TEXT,
deprecated JSONB,
extend TEXT,
workspace BOOLEAN,
plugin TEXT,
watch TEXT,
condition TEXT,
condition_script TEXT,
condition_script_runner_args TEXT,
watch JSONB,
condition JSONB,
condition_script JSONB,
condition_script_runner_args JSONB,
ignore_errors BOOLEAN,
force BOOLEAN,
env_files TEXT,
env TEXT,
env_files JSONB,
env JSONB,
cwd TEXT,
alias TEXT,
linux_alias TEXT,
windows_alias TEXT,
mac_alias TEXT,
install_crate TEXT,
install_crate_args TEXT,
install_script TEXT,
install_crate JSONB,
install_crate_args JSONB,
install_script JSONB,
command TEXT,
args TEXT,
script TEXT,
args JSONB,
script JSONB,
script_runner TEXT,
script_runner_args TEXT,
script_runner_args JSONB,
script_extension TEXT,
run_task TEXT,
dependencies TEXT,
toolchain TEXT,
linux TEXT,
windows TEXT,
mac TEXT
run_task JSONB,
dependencies JSONB,
toolchain JSONB,
linux JSONB,
windows JSONB,
mac JSONB
);

CREATE TABLE steps
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
name TEXT NOT NULL,
config TEXT NOT NULL
name TEXT NOT NULL,
config JSONB NOT NULL
);

CREATE TABLE execution_plans
(
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
steps TEXT NOT NULL,
steps_to_run TEXT NOT NULL,
name TEXT NOT NULL
steps JSONB NOT NULL,
steps_to_run JSONB NOT NULL,
name TEXT NOT NULL
);

Loading

0 comments on commit 392dcf7

Please sign in to comment.