feat: support SQL database creation with initial properties#250
feat: support SQL database creation with initial properties#250v-alexmoraru wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for creating SQL_DATABASE items with an optional creationPayload so initial SQL Database properties (and creation mode) can be set at creation time.
Changes:
- Add
_build_sql_database_creation_payload(and backup retention validation) and wire it intoadd_type_specific_payloadforItemType.SQL_DATABASE. - Introduce new SQL Database constants (creation modes, backup retention bounds) and CommonErrors helpers for validation messaging.
- Add unit tests covering payload generation and validation scenarios; add a changelog entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_utils/test_fab_cmd_mkdir_utils.py | Adds tests for SQLDatabase creation payload building/validation. |
| src/fabric_cli/utils/fab_cmd_mkdir_utils.py | Builds/validates SQLDatabase creationPayload and attaches it during mkdir. |
| src/fabric_cli/errors/common.py | Adds error message helpers for SQLDatabase creation mode/property validation. |
| src/fabric_cli/core/fab_constant.py | Adds SQLDatabase constants for creation modes and backup retention limits. |
| .changes/unreleased/added-20260618-043404.yaml | Records changelog entry for the new SQL db creation support. |
| backup_retention_days = params.get("backupretentiondays") | ||
| collation = params.get("collation") | ||
|
|
||
| if mode is None and backup_retention_days is None and collation is None: |
There was a problem hiding this comment.
what if one of them isnt none? what should be the outcome?
| creation_payload = _build_sql_database_creation_payload(params) | ||
| if creation_payload: | ||
| payload_dict["creationPayload"] = creation_payload |
There was a problem hiding this comment.
| creation_payload = _build_sql_database_creation_payload(params) | |
| if creation_payload: | |
| payload_dict["creationPayload"] = creation_payload | |
| creation_payload = _build_sql_database_creation_payload_if_exists(params) | |
| if creation_payload: | |
| payload_dict["creationPayload"] = creation_payload |
| else: | ||
| mode = fab_constant.SQL_DATABASE_CREATION_MODE_NEW |
There was a problem hiding this comment.
why we need to set something at all if not provided?
| raise ValueError() | ||
| except (ValueError, TypeError): | ||
| raise FabricCLIError( | ||
| CommonErrors.invalid_backup_retention_days(str(value), min_days, max_days), |
There was a problem hiding this comment.
in the other pr you already doing it, consider having one pr that implements both.
| if mode is None and backup_retention_days is None and collation is None: | ||
| return None | ||
|
|
||
| # Resolve and validate mode |
There was a problem hiding this comment.
i dont think we should validate the creationPayload input, it is the workload responsibility. we do need to make sure we support creating the artifact with those optional params.
Fixes #148.
Builds proper payload for creation of SQL databases with initial properties such as backup retention days, mode or collation.