Skip to content

Commit

Permalink
Script for deps (#188)
Browse files Browse the repository at this point in the history
* Delete purchase_invoice, line_items on failed exports from hh2, type-check for current_state

* Refactor deps schedule to run post Job import

* Remove dep setting trigger, add logger

* Remove mock object

* Add details while logging

* Fyle Card <> Vendor Mapping setup (#181)

* Fyle Card <> Vendor Mapping setup

* Added script to add mapping_settings

* Fix post release script

* Modified script, added additional test case

* lint fix

* modify post-release script

* Disable sage fields (#183)

* Fyle Card <> Vendor Mapping setup

* Added script to add mapping_settings

* Fix post release script

* Projects and Deps fields disable v1

* Modified script, added additional test case

* lint fix

* modify post-release script

* bump accounting-mapping version

* modify the variable_name, add conditional update

* Add example objects

* Added loggers

* Added test cases

* Modify test case, add filter in dep field settings

* Dependent Field optimizations (#185)

* Fyle Card <> Vendor Mapping setup

* Added script to add mapping_settings

* Fix post release script

* Projects and Deps fields disable v1

* Modified script, added additional test case

* lint fix

* modify post-release script

* bump accounting-mapping version

* modify the variable_name, add conditional update

* Add example objects

* Added loggers

* Added test cases

* Dependent Field optimizations

* fix failing test

* Fix post-release script

* Fix the merged issues

* Add filters and change log

* Added script for disabling cost_code and cost_category

* reorder the script

* add rollback begin
  • Loading branch information
Hrishabh17 authored Jun 14, 2024
1 parent f31ef1f commit c7faa22
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions scripts/004_disable_deps_db_and_fyle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
Script to disable Cost Code and Cost Category
Future Modifications:
1. Add Project Name/Id if specific Cost Code are to be deleted.
2. Add Cost Code Name/Id and Project Name/Id if specific Cost Category are to be deleted.
CSV Template for Cost Code:
cost_code_name
CSV Template for Cost Category:
cost_category_name
*/


/*
Steps for Cost Code:
1. Create a temp table to store the data from the CSV
2. Copy the data from the CSV to the temp table
3. Delete the Cost Code from destination_attributes
4. Delete the Cost Category having the Cost Code as the mentioned Cost Code
5. Delete from the fyle dependent_fields_values table where expense_field_value is the Cost Code
6. Delete from the fyle dependent_fields_values table where parent_expense_field_value is the Cost Code
*/


------ Cost Code ------
rollback;
begin;

create temp table temp_cost_code (
cost_code_name TEXT
);

--- update the path here
\copy temp_cost_code (cost_code_name)
from '/Users/hrishabh/Desktop/cost_code_org_name.csv' WITH CSV HEADER;

--- update the workspace id here
delete from destination_attributes
where attribute_type = 'COST_CODE'
and value in (
select cost_code_name from temp_cost_code
) and workspace_id = _workspace_id;

--- update the workspace id here
delete from cost_category
where cost_code_name in (
select cost_code_name from temp_cost_code
)
and workspace_id = _workspace_id;



---- Fyle DB ----
--- update the org id here
rollback;
begin;

delete from platform_schema.dependent_expense_field_values
where expense_field_value in (
select cost_code_name from temp_cost_code
)
and org_id = _org_id;

--- update the org id here
rollback;
begin;

delete from platform_schema.dependent_expense_field_values
where parent_expense_field_value in (
select cost_code_name from temp_cost_code
)
and org_id = _org_id;




/*
Steps for Cost Category:
1. Create a temp table to store the data from the CSV
2. Copy the data from the CSV to the temp table
3. Delete from the Cost Category table where Cost Category is the mentioned Cost Category
4. Delete from the fyle dependent_fields_values table where expense_field_value is the Cost Category
*/

----- Cost Category ------
rollback;
begin;

create temp table temp_cost_category (
cost_category_name TEXT
);

--- update the path here
\copy temp_cost_category (cost_category_name)
from '/Users/hrishabh/Desktop/cost_category_org_name.csv' WITH CSV HEADER;

--- update the workspace id here
delete from cost_category
where name in (
select cost_category_name from temp_cost_category
)
and workspace_id = _workspace_id;

---- Fyle DB ----
--- update the org id here
rollback;
begin;

delete from platform_schema.dependent_expense_field_values
where expense_field_value in (
select cost_category_name from temp_cost_category
)
and org_id = _org_id;

0 comments on commit c7faa22

Please sign in to comment.