Repository: AgnostiqHQ/covalent (python)
Issue: Running any CLI command will fail on a new machine
### Environment

- **Covalent version**: 0.222.0rc0
- **Python version**: 3.8.15
- **Operating system**: Ubuntu 20.04


### What is happening?

Executing any CLI command throws an error now since it is unable to find the non-existent directory for the database, which it is looking for when because we are executing code during import time. This is why the tests are currently failing on `develop` branch.

### How can we reproduce the issue?

After doing a `covalent purge -Hy` and deleting the `~/.local/share/covalent` directory if we run any command like `covalent db migrate` command, which is usually done as part of the test pipeline it will throw a long traceback with the final error being:

```python
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
```

This happens because the database directory now only gets created after `covalent start` command is run.

### What should happen?

No error should be thrown when running a CLI command.

### Any suggestions?

Ideally, we should not be executing anything during import time (which happens to be the case for this issue), but resolving that might open up a different can of worms. So an alternative solution is to move the following line back to `ConfigManager` class' definition from its current place in `_graceful_start()`:

```python
Path(get_config("dispatcher.db_path")).parent.mkdir(parents=True, exist_ok=True)
```
Pull request description: Fixed db path creation
<!--
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Increment the version number in the /VERSION file. If this is a bugfix, increment the patch version (the rightmost number), for example 0.18.2 becomes 0.18.3. If it's a new feature, increment the minor version (the middle number), for example 0.18.2 becomes 0.19.0.
⚠️ Add a note to /CHANGELOG.md with your version number and the date, summarizing the changes.
⚠️ If your pull request fixes an open issue, please link to the issue.
⚠️ Rebase the latest changes from the develop branch. Assuming origin points to https://github.com/AgnostiqHQ/covalent, you should run git rebase origin/develop.
-->

- [x] I have added the tests to cover my changes.
- [x] I have updated the documentation and CHANGELOG accordingly.
- [x] I have read the CONTRIBUTING document.

Resolves #1621 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 033e7edd..4c63fa14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
+- DB path creation now takes place at import time so that the CLI commands don't fail
 - Raise error on dispatching a non-lattice
 - Helpful message when trying to dispatch a workflow when covalent server is not available
 - Open UI preview of transport graph when `lattice.draw()` is invoked and print URL of the same
diff --git a/covalent/_shared_files/config.py b/covalent/_shared_files/config.py
index e24405a8..f7fe27f6 100644
--- a/covalent/_shared_files/config.py
+++ b/covalent/_shared_files/config.py
@@ -59,6 +59,7 @@ class ConfigManager:
 
         Path(self.get("sdk.log_dir")).mkdir(parents=True, exist_ok=True)
         Path(self.get("sdk.executor_dir")).mkdir(parents=True, exist_ok=True)
+        Path(self.get("dispatcher.db_path")).parent.mkdir(parents=True, exist_ok=True)
 
     def generate_default_config(self) -> None:
         """
diff --git a/covalent_dispatcher/_cli/service.py b/covalent_dispatcher/_cli/service.py
index 41f4cc59..4be089b5 100644
--- a/covalent_dispatcher/_cli/service.py
+++ b/covalent_dispatcher/_cli/service.py
@@ -225,7 +225,6 @@ def _graceful_start(
     Path(get_config("dispatcher.results_dir")).mkdir(parents=True, exist_ok=True)
     Path(get_config("dispatcher.log_dir")).mkdir(parents=True, exist_ok=True)
     Path(get_config("user_interface.log_dir")).mkdir(parents=True, exist_ok=True)
-    Path(get_config("dispatcher.db_path")).parent.mkdir(parents=True, exist_ok=True)
 
     return port
 


Test patch:
diff --git a/tests/covalent_tests/shared_files/config_test.py b/tests/covalent_tests/shared_files/config_test.py
index 32a71c86..cd772109 100644
--- a/tests/covalent_tests/shared_files/config_test.py
+++ b/tests/covalent_tests/shared_files/config_test.py
@@ -58,6 +58,7 @@ def test_config_manager_init_write_update_config(
     config_keys = [
         "sdk.log_dir",
         "sdk.executor_dir",
+        "dispatcher.db_path",
     ]
 
     server_specific_config_keys = [
@@ -65,7 +66,6 @@ def test_config_manager_init_write_update_config(
         "dispatcher.results_dir",
         "dispatcher.log_dir",
         "user_interface.log_dir",
-        "dispatcher.db_path",
     ]
 
     with tempfile.TemporaryDirectory() as tmp_dir: