diff --git a/src/lib/diesel_schemas/custom_to_fro.rs b/src/lib/diesel_schemas/custom_to_fro.rs index e69de29b..8b137891 100644 --- a/src/lib/diesel_schemas/custom_to_fro.rs +++ b/src/lib/diesel_schemas/custom_to_fro.rs @@ -0,0 +1 @@ + diff --git a/src/lib/diesel_schemas/down.sql b/src/lib/diesel_schemas/down.sql index a7fe16f3..94283ebd 100644 --- a/src/lib/diesel_schemas/down.sql +++ b/src/lib/diesel_schemas/down.sql @@ -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; diff --git a/src/lib/diesel_schemas/mod.rs b/src/lib/diesel_schemas/mod.rs index 7b2264f7..c68013d1 100644 --- a/src/lib/diesel_schemas/mod.rs +++ b/src/lib/diesel_schemas/mod.rs @@ -3,69 +3,7 @@ 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, - cli_arguments -> Nullable, // Optional vector serialized to JSON/text - } -} - -table! { - // Stores the state of a flow - flow_states (id) { - id -> Integer, - time_summary -> Jsonb, - forced_plugin -> Nullable, - } -} - -table! { - // ModifyConfig for modifying core tasks - modify_configs (id) { - id -> Integer, - private -> Nullable, - namespace -> Nullable, - } -} - -table! { - // ConfigSection, the main configuration store - config_sections (id) { - id -> Integer, - skip_core_tasks -> Nullable, - modify_core_tasks -> Nullable, // Assuming ModifyConfig is serialized to JSON-like format - init_task -> Nullable, - end_task -> Nullable, - on_error_task -> Nullable, - legacy_migration_task -> Nullable, - additional_profiles -> Nullable, // Assuming Vec is serialized to JSON-like format - min_version -> Nullable, - default_to_workspace -> Nullable, - skip_git_env_info -> Nullable, - skip_rust_env_info -> Nullable, - skip_crate_env_info -> Nullable, - reduce_output -> Nullable, - time_summary -> Nullable, - load_cargo_aliases -> Nullable, - main_project_member -> Nullable, - load_script -> Nullable, // Assuming ScriptValue can be serialized to JSON-like format - linux_load_script -> Nullable, - windows_load_script -> Nullable, - mac_load_script -> Nullable, - unstable_features -> Nullable, // Assuming IndexSet 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, @@ -73,54 +11,56 @@ table! { category -> Nullable, disabled -> Nullable, private -> Nullable, - deprecated -> Nullable, // Assuming DeprecationInfo serialized to text + deprecated -> Nullable, // Assuming DeprecationInfo is serialized to JSONB extend -> Nullable, workspace -> Nullable, plugin -> Nullable, - watch -> Nullable, // Assuming TaskWatchOptions serialized to text - condition -> Nullable, // Assuming TaskCondition serialized to text - condition_script -> Nullable, - condition_script_runner_args -> Nullable, + watch -> Nullable, // Assuming TaskWatchOptions is serialized to JSONB + condition -> Nullable, // Assuming TaskCondition is serialized to JSONB + condition_script -> Nullable, // Assuming ConditionScriptValue is serialized to JSONB + condition_script_runner_args -> Nullable, // Assuming Vec is serialized to JSONB ignore_errors -> Nullable, force -> Nullable, - env_files -> Nullable, // Assuming Vec serialized to text - env -> Nullable, // Assuming IndexMap serialized to text + env_files -> Nullable, // Assuming Vec is serialized to JSONB + env -> Nullable, // Assuming IndexMap is serialized to JSONB cwd -> Nullable, alias -> Nullable, linux_alias -> Nullable, windows_alias -> Nullable, mac_alias -> Nullable, - install_crate -> Nullable, // Assuming InstallCrate serialized to text - install_crate_args -> Nullable, - install_script -> Nullable, // Assuming ScriptValue serialized to text + install_crate -> Nullable, // Assuming InstallCrate is serialized to JSONB + install_crate_args -> Nullable, // Assuming Vec is serialized to JSONB + install_script -> Nullable, // Assuming ScriptValue is serialized to JSONB command -> Nullable, - args -> Nullable, - script -> Nullable, // Assuming ScriptValue serialized to text + args -> Nullable, // Assuming Vec is serialized to JSONB + script -> Nullable, // Assuming ScriptValue is serialized to JSONB script_runner -> Nullable, - script_runner_args -> Nullable, + script_runner_args -> Nullable, // Assuming Vec is serialized to JSONB script_extension -> Nullable, - run_task -> Nullable, // Assuming RunTaskInfo serialized to text - dependencies -> Nullable, // Assuming Vec serialized to text - toolchain -> Nullable, - linux -> Nullable, // Assuming PlatformOverrideTask serialized to text - windows -> Nullable, - mac -> Nullable, + run_task -> Nullable, // Assuming RunTaskInfo is serialized to JSONB + dependencies -> Nullable, // Assuming Vec is serialized to JSONB + toolchain -> Nullable, // Assuming ToolchainSpecifier is serialized to JSONB + linux -> Nullable, // Assuming PlatformOverrideTask is serialized to JSONB + windows -> Nullable, + mac -> Nullable, } } 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 serialized to JSON/text - steps_to_run -> Jsonb, // Assuming std::ops::Range serialized to JSON/text + steps -> Jsonb, // Assuming Vec is serialized to JSONB + steps_to_run -> Jsonb, // Assuming std::ops::Range is serialized to JSONB name -> Text, } } diff --git a/src/lib/diesel_schemas/up.sql b/src/lib/diesel_schemas/up.sql index 4a844d6b..1716cf10 100644 --- a/src/lib/diesel_schemas/up.sql +++ b/src/lib/diesel_schemas/up.sql @@ -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, @@ -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 ); - diff --git a/src/lib/types.rs b/src/lib/types.rs index 3c485b87..e3417ee4 100755 --- a/src/lib/types.rs +++ b/src/lib/types.rs @@ -338,8 +338,6 @@ impl<'de> serde::Deserialize<'de> for SerdeRegex { } } -#[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = flow_info))] #[derive(Serialize, Deserialize, Debug, Clone)] /// Holds flow information pub struct FlowInfo { @@ -364,8 +362,6 @@ pub struct FlowInfo { } #[derive(Debug, Clone, Default)] -#[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = flow_state))] /// Holds mutable flow state pub struct FlowState { /// timing info for summary @@ -1141,83 +1137,172 @@ pub enum ConditionScriptValue { } #[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = task))] +#[cfg_attr(feature = "diesel", diesel(table_name = task))] #[derive(Serialize, Deserialize, Debug, Clone, Default)] /// Holds a single task configuration such as command and dependencies list pub struct Task { /// if true, it should ignore all data in base task + #[serde(skip_serializing_if = "Option::is_none")] pub clear: Option, + /// Task description + #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, + /// Category name used to document the task + #[serde(skip_serializing_if = "Option::is_none")] pub category: Option, + /// if true, the command/script of this task will not be invoked, dependencies however will be + #[serde(skip_serializing_if = "Option::is_none")] pub disabled: Option, + /// if true, the task is hidden from the list of available tasks and also cannot be invoked directly from cli + #[serde(skip_serializing_if = "Option::is_none")] pub private: Option, + /// if not false, this task is defined as deprecated + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub deprecated: Option, + /// Extend any task based on the defined name + #[serde(skip_serializing_if = "Option::is_none")] pub extend: Option, + /// set to false to notify cargo-make that this is not a workspace and should not call task for every member (same as --no-workspace CLI flag) + #[serde(skip_serializing_if = "Option::is_none")] pub workspace: Option, + /// Optional plugin used to execute the task + #[serde(skip_serializing_if = "Option::is_none")] pub plugin: Option, + /// set to true to watch for file changes and invoke the task operation + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub watch: Option, + /// if provided all condition values must be met in order for the task to be invoked (will not stop dependencies) + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub condition: Option, + /// if script exit code is not 0, the command/script of this task will not be invoked, dependencies however will be + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub condition_script: Option, + /// The script runner arguments before the script file path + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub condition_script_runner_args: Option>, + /// if true, any error while executing the task will be printed but will not break the build + #[serde(skip_serializing_if = "Option::is_none")] pub ignore_errors: Option, + /// DEPRECATED, replaced with ignore_errors + #[serde(skip_serializing_if = "Option::is_none")] pub force: Option, + /// The env files to setup before running the task commands + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub env_files: Option>, + /// The env vars to setup before running the task commands + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub env: Option>, + /// The working directory for the task to execute its command/script + #[serde(skip_serializing_if = "Option::is_none")] pub cwd: Option, + /// if defined, task points to another task and all other properties are ignored + #[serde(skip_serializing_if = "Option::is_none")] pub alias: Option, + /// acts like alias if runtime OS is Linux (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] pub linux_alias: Option, + /// acts like alias if runtime OS is Windows (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] pub windows_alias: Option, + /// acts like alias if runtime OS is Mac (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] pub mac_alias: Option, + /// if defined, the provided crate will be installed (if needed) before running the task + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub install_crate: Option, + /// additional cargo install arguments + #[serde(skip_serializing_if = "Option::is_none")] pub install_crate_args: Option>, + /// if defined, the provided script will be executed before running the task + #[serde(skip_serializing_if = "Option::is_none")] pub install_script: Option, + /// The command to execute + #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, + /// The command args + #[serde(skip_serializing_if = "Option::is_none")] pub args: Option>, + /// If command is not defined, and script is defined, the provided script will be executed + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub script: Option, + /// The script runner (defaults to cmd in windows and sh for other platforms) + #[serde(skip_serializing_if = "Option::is_none")] pub script_runner: Option, + /// The script runner arguments before the script file path + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub script_runner_args: Option>, + /// The script file extension + #[serde(skip_serializing_if = "Option::is_none")] pub script_extension: Option, + /// The task name to execute + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub run_task: Option, + /// A list of tasks to execute before this task + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub dependencies: Option>, + /// The rust toolchain used to invoke the command or install the needed crates/components + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub toolchain: Option, + /// override task if runtime OS is Linux (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub linux: Option, + /// override task if runtime OS is Windows (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub windows: Option, + /// override task if runtime OS is Mac (takes precedence over alias) + #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "diesel", diesel(deserialize_as = diesel::pg::types::sql_types::Jsonb))] pub mac: Option, } @@ -2122,8 +2207,6 @@ pub enum Extend { List(Vec), } -#[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = modify_config))] #[derive(Serialize, Deserialize, Debug, Clone)] /// Holds properties to modify the core tasks pub struct ModifyConfig { @@ -2177,8 +2260,6 @@ impl UnstableFeature { } } -#[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = config_section))] #[derive(Serialize, Deserialize, Debug, Clone, Default)] /// Holds the configuration found in the makefile toml config section. pub struct ConfigSection { @@ -2468,18 +2549,19 @@ impl ExternalConfig { } #[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = step))] +#[cfg_attr(feature = "diesel", diesel(table_name = step))] #[derive(Serialize, Deserialize, Clone, Debug)] /// Execution plan step to execute pub struct Step { /// The task name pub name: String, + /// The task config pub config: Task, } #[cfg_attr(feature = "diesel", derive(diesel::Queryable, diesel::Insertable))] -// #[cfg_attr(feature = "diesel", diesel(table_name = execution_plan))] +#[cfg_attr(feature = "diesel", diesel(table_name = execution_plan))] #[derive(Serialize, Deserialize, Clone, Debug)] /// Execution plan which defines all steps to run and the order to run them pub struct ExecutionPlan {