renamingTable¶
Group destructive · Migrations only · Since 0.15.0
Diagnostic lint/renamingTable
Sources: inspired by squawk/renaming-table
Description¶
Renaming tables may break existing queries and application code.
Renaming a table that is being referenced by existing applications, views, functions, or foreign keys can cause unexpected downtime. Consider creating a view with the old table name pointing to the new table, or carefully coordinate the rename with application deployments.
Examples¶
Invalid¶
ALTER TABLE users RENAME TO app_users;
code-block.sql:1:1 lint/renamingTable ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Renaming a table may break existing clients.
> 1 │ ALTER TABLE users RENAME TO app_users;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
i Consider creating a view with the old table name instead, or coordinate the rename carefully with application deployments.
How to configure¶
{
"linter": {
"rules": {
"renamingTable": "error"
}
}
}
How to suppress¶
Suppress this diagnostic with a comment:
-- pgls-ignore renamingTable