Skip to content

v9.2.1 migrate firewall tables to firewall schema (#4793, DB layer)#4796

Draft
tpurschke wants to merge 16 commits into
CactuseSecurity:developfrom
tpurschke:feat/firewall-schema-4793
Draft

v9.2.1 migrate firewall tables to firewall schema (#4793, DB layer)#4796
tpurschke wants to merge 16 commits into
CactuseSecurity:developfrom
tpurschke:feat/firewall-schema-4793

Conversation

@tpurschke

@tpurschke tpurschke commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Issue

Implements #4793 — moving the firewall configuration tables out of the public schema into a new firewall schema (renaming 9 of them) and propagating the rename through the database, Hasura metadata, GraphQL calls and the Python importer.

Scope

This PR now covers the DB, Hasura metadata, GraphQL and Python importer layers. Only the C# layer is deferred (see "Deferred" below). The end-to-end stack still needs an installer/integration run before merge (see "Verification").

What's included

Database

Schema move + renames (22 tables, 9 renamed):

  • New fworch-create-tables-firewall.sql creates the firewall schema and all 22 tables, and adds firewall to the database search_path via a current_database() DO-block — so the 13 non-renamed tables need no reference changes.
  • Removed the tables from fworch-create-tables-base.sql, deleted fworch-create-tables-rule-related.sql, wired the new file first in install-database.yml.
old (public) new (firewall)
object nw_object
objgrp nw_object_group
service nw_service
svcgrp nw_service_group
usr nw_user
usergrp nw_user_group
rule_svc_resolved rule_nw_service_resolved
rule_nwobj_resolved rule_nw_object_resolved
rule_user_resolved rule_nw_user_resolved

(the other 13 — rule, rule_metadata, parent_rule_type, rule_from/to/service, rulebase, rulebase_link, rule_enforced_on_gateway, rule_from_zone, rule_to_zone, rule_time, zone — keep their names and just move schema.)

References updated (surgically — overloaded names like changelog_object, objgrp_flat, rule_service, modelling.service were left untouched and verified): foreign keys, constraints, indices (index/constraint names preserved), views-materialized, idempotent api-funcs + views-changes, and maintenance scripts. Where a query used a table name as a column qualifier (object.obj_id), the renamed table is aliased back to its old name so qualifiers still resolve.

Upgrade path: new 9.2.1.sql — idempotent SET SCHEMA + RENAME for existing installs (FKs/sequences move with the tables via OID), plus the search_path. Bumped product_version to 9.2.1 and added a revision-history entry. Historical upgrade scripts are intentionally unchanged — they run before the 9.2.1 cutover, while the tables still live in public.

Hasura metadata

  • replace_metadata.json regenerated so the moved/renamed tables are tracked in the firewall schema, with custom root-field names (firewall_rule, update_firewall_nw_object, …) and relationships updated accordingly.

GraphQL

  • ~86 .graphql query/fragment files updated to the new root-field / table names (rulefirewall_rule, objectfirewall_nw_object, update_usrupdate_firewall_nw_user, …).

Python importer

  • model_controllers (fwconfig_import, fwconfig_import_object, fwconfig_import_rule, fwconfig_import_gateway, rulebase_link_controller) and services/uid2id_mapper updated to the renamed mutation/query root fields and result keys.
  • Importer unit tests and tests-integration/tasks/test-importer.yml updated accordingly.

Verification

  • Full grep sweep of the DB SQL tree shows no stale references to the renamed tables.
  • Not yet validated against a live stack: needs a full installer + importer integration run to confirm the Hasura custom root fields resolve and the importer pipeline writes against the new schema. The search_path cutover relies on later install steps running on fresh DB connections — confirm on a real install.

tpurschke and others added 2 commits June 21, 2026 13:38
Move the 22 firewall tables from public to a new firewall schema and
rename 9 of them (object->nw_object, service->nw_service, etc.) per
issue CactuseSecurity#4793. Creation now lives in fworch-create-tables-firewall.sql,
which also adds firewall to the database search_path so unqualified
references to the 13 non-renamed tables keep resolving. FK, constraint
and index references to the renamed tables are updated; triggers need
no change.

WIP: idempotent functions/views, Hasura metadata, GraphQL, C# and
Python layers still pending.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Complete the database layer of issue CactuseSecurity#4793:
- update materialized views, idempotent functions/views (api-funcs,
  views-changes) and maintenance scripts to the renamed firewall tables,
  aliasing renamed tables back to their old name where queries use the
  table name as a column qualifier
- add upgrade 9.1.9.sql: idempotent SET SCHEMA + RENAME for existing
  installs (OID-based FKs/sequences move with the tables) plus the
  firewall search_path
- bump product_version to 9.1.9 and add a revision-history entry

Historical upgrade scripts are intentionally left referencing the old
public names: they run before the 9.1.9 cutover, when the tables still
live in public.

Hasura metadata, GraphQL, C# and Python layers are deferred to a
live-stack workflow as agreed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tpurschke tpurschke self-assigned this Jun 21, 2026
@tpurschke tpurschke changed the title feat(db): migrate firewall tables to firewall schema (#4793, DB layer) v9.2.1 migrate firewall tables to firewall schema (#4793, DB layer) Jun 21, 2026
tpurschke and others added 8 commits June 21, 2026 15:10
The request.reqtask/reqelement/impltask/implelement foreign keys
reference object/service/usr without quotes, which the earlier
quoted-identifier replacement missed, so a new install failed in
fworch-create-foreign-keys.sql with 'relation "service" does not
exist'. Point them at firewall.nw_object/nw_service/nw_user.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the 22 firewall tables to the firewall schema in
replace_metadata.json (132 table references). FK-based relationships
resolve via the moved constraints; relationship names are unchanged, so
only the auto-generated root field names gain the firewall_ prefix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Hasura prefixes root fields with the schema name, so moving the tables
to the firewall schema renames the GraphQL root fields/types (rule ->
firewall_rule, object -> firewall_nw_object, ...).

- GraphQL (.graphql): rename root query/mutation fields and generated
  type names to firewall_*; nested relationship field names are
  unchanged (relationship names were preserved in the metadata), so
  fragments and nested selections keep working.
- Importer (Python): update inline GraphQL strings, dynamically built
  mutation/response keys (RefType enum values, group prefix vs the
  public _flat tables) and response-root-key access to firewall_*.

C# needs no changes: the API client extracts the single root field
positionally (data.First) and relationship-name JSON bindings are
unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant