feat: ability to create a project #9

Merged
matous-volf merged 50 commits from feat/project-create into main 2024-08-18 21:36:06 +00:00
3 changed files with 51 additions and 0 deletions
Showing only changes of commit f0e050c3f8 - Show all commits

9
diesel.toml Normal file
View File

@ -0,0 +1,9 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/schema.rs"
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
[migrations_directory]
dir = "/home/matous/Documents/todo-baggins/migrations"

View File

@ -0,0 +1,6 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
DROP FUNCTION IF EXISTS diesel_set_updated_at();

View File

@ -0,0 +1,36 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
coderabbitai[bot] commented 2024-08-17 10:53:11 +00:00 (Migrated from github.com)
Review

Clarify the auto-generated nature of the file.

The comments indicate that this file was automatically created by Diesel. Ensure that any manual edits are documented to avoid confusion in future migrations.

**Clarify the auto-generated nature of the file.** The comments indicate that this file was automatically created by Diesel. Ensure that any manual edits are documented to avoid confusion in future migrations. <!-- This is an auto-generated comment by CodeRabbit -->
-- Sets up a trigger for the given table to automatically set a column called
-- `updated_at` whenever the row is modified (unless `updated_at` was included
-- in the modified columns)
--
-- # Example
--
-- ```sql
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
--
-- SELECT diesel_manage_updated_at('users');
-- ```
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
BEGIN
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
END;
$$ LANGUAGE plpgsql;
coderabbitai[bot] commented 2024-08-17 10:53:11 +00:00 (Migrated from github.com)
Review

Tip

Codebase Verification

Ensure usage of diesel_manage_updated_at function for automatic updates.

The diesel_manage_updated_at function is not actively used in the migration files to set up triggers for automatic updates to the updated_at column. Please ensure that this function is called for each table that requires this functionality.

Analysis chain

Ensure proper usage of the diesel_manage_updated_at function.

The function diesel_manage_updated_at is designed to set up a trigger for automatically updating the updated_at column. Make sure that this function is called for each table that requires this functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `diesel_manage_updated_at` is used for each table requiring automatic `updated_at` updates.

# Test: Search for the function usage across the SQL migration files.
rg --type sql $'SELECT diesel_manage_updated_at'

Length of output: 148


Script:

#!/bin/bash
# Description: Search for active (uncommented) usage of the `diesel_manage_updated_at` function in SQL migration files.
rg --type sql 'diesel_manage_updated_at' --invert-match --fixed-strings '--'

Length of output: 4075

> [!TIP] > Codebase Verification **Ensure usage of `diesel_manage_updated_at` function for automatic updates.** The `diesel_manage_updated_at` function is not actively used in the migration files to set up triggers for automatic updates to the `updated_at` column. Please ensure that this function is called for each table that requires this functionality. <details> <summary>Analysis chain</summary> **Ensure proper usage of the `diesel_manage_updated_at` function.** The function `diesel_manage_updated_at` is designed to set up a trigger for automatically updating the `updated_at` column. Make sure that this function is called for each table that requires this functionality. </details> <details> <summary>Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify that `diesel_manage_updated_at` is used for each table requiring automatic `updated_at` updates. # Test: Search for the function usage across the SQL migration files. rg --type sql $'SELECT diesel_manage_updated_at' ``` Length of output: 148 --- Script: ```shell #!/bin/bash # Description: Search for active (uncommented) usage of the `diesel_manage_updated_at` function in SQL migration files. rg --type sql 'diesel_manage_updated_at' --invert-match --fixed-strings '--' ``` Length of output: 4075 </details> <!-- This is an auto-generated comment by CodeRabbit -->
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
BEGIN
IF (
NEW IS DISTINCT FROM OLD AND
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
) THEN
NEW.updated_at := current_timestamp;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;