Skip to content

docs: add ban-drop-table docs #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/rule_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
| ---- | ---- |
| [ban-drop-column](https://squawkhq.com/docs/ban-drop-column) |[banDropColumn](./rules/ban-drop-column) |
| [ban-drop-not-null](https://squawkhq.com/docs/ban-drop-not-null) |[banDropNotNull](./rules/ban-drop-not-null) |
| [ban-drop-table](https://squawkhq.com/docs/ban-drop-table) |[banDropTable](./rules/ban-drop-table) |
1 change: 1 addition & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Rules that detect potential safety issues in your code.
| --- | --- | --- |
| [banDropColumn](./rules/ban-drop-column) | Dropping a column may break existing clients. | <span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span> |
| [banDropNotNull](./rules/ban-drop-not-null) | Dropping a NOT NULL constraint may break existing clients. | <span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span> |
| [banDropTable](./rules/ban-drop-table) | Dropping a table may break existing clients. | <span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span> |

[//]: # (END RULES_INDEX)

Expand Down
43 changes: 43 additions & 0 deletions docs/rules/ban-drop-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# banDropTable
**Diagnostic Category: `lint/safety/banDropTable`**

**Since**: `vnext`

> [!NOTE]
> This rule is recommended. A diagnostic error will appear when linting your code.

**Sources**:
- Inspired from: <a href="https://squawkhq.com/docs/ban-drop-table" target="_blank"><code>squawk/ban-drop-table</code></a>

## Description
Dropping a table may break existing clients.

Update your application code to no longer read or write the table.

Once the table is no longer needed, you can delete it by running the command "DROP TABLE mytable;".

This command will permanently remove the table from the database and all its contents.
Be sure to back up the table before deleting it, just in case you need to restore it in the future.

## Examples

```sql
drop table some_table;
```

```sh
code-block.sql lint/safety/banDropTable ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Dropping a table may break existing clients.

i Update your application code to no longer read or write the table, and only then delete the table. Be sure to create a backup.


```

## How to configure
```toml title="pglt.toml"
[linter.rules.safety]
banDropTable = "error"

```
11 changes: 11 additions & 0 deletions docs/schemas/0.0.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@
}
]
},
"banDropTable": {
"description": "Dropping a table may break existing clients.",
"anyOf": [
{
"$ref": "#/definitions/RuleConfiguration"
},
{
"type": "null"
}
]
},
"recommended": {
"description": "It enables the recommended rules for this group",
"type": [
Expand Down
11 changes: 11 additions & 0 deletions docs/schemas/latest/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@
}
]
},
"banDropTable": {
"description": "Dropping a table may break existing clients.",
"anyOf": [
{
"$ref": "#/definitions/RuleConfiguration"
},
{
"type": "null"
}
]
},
"recommended": {
"description": "It enables the recommended rules for this group",
"type": [
Expand Down