Skip to content

Add default schemas that are unique - #6047

Open
rbev wants to merge 6 commits into
masterfrom
default-schemas
Open

rbev wants to merge 6 commits into
masterfrom
default-schemas

Conversation

@rbev

@rbev rbev commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Separate primary and audit SQL schemas

  • Keep primary and audit tables in separate default schemas rather than supporting shared-schema installations.
  • To ensure that no data loss occurs if a misconfiguration points both audit and error at the same schema it is now checked before making changes.

Why

The schema default was to share the same schema, however there was no testing that ensures this is actually supported.

For SQL Server and PostgreSQL:

  • Default Database/Schema to psw_sc for primary instances and psw_audit for audit instances when the setting is absent or blank.
  • Fail setup before applying migrations if the target schema contains the other instance's migration history table. Primary instances reject __AuditMigrationsHistory; audit instances reject __EFMigrationsHistory.
  • Allow the other instance's migration history table in a different schema in the same database.

Custom schema names remain supported. Operators must create the schema and grant the configured user rights before running setup. Setup does not create schemas or move data.

Update persistence manifests, default-schema telemetry, and documentation to match.

@rbev rbev self-assigned this Oct 22, 2026
@rbev
rbev requested a review from johnsimons October 23, 2026 01:45
Comment thread docs/sql-persister-schemas.md Outdated
@rbev
rbev requested a review from abparticular October 23, 2026 03:31

@warwickschroeder warwickschroeder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things im not sure about:

  1. the default schema naming
  2. Throwing if error and audit are on the same schema without a very good reason.

Comment thread docs/sql-persister-schemas.md Outdated
Comment thread docs/sql-persister-schemas.md Outdated
Comment thread docs/sql-persister-schemas.md Outdated
Comment thread docs/usage-report.md Outdated
| `Storage.BodyStorage.Type` | `RavenAttachments`, `FileSystem`, `AzureBlob`, `S3` | the persister | 6.20.0 |
| `Limits.MaxBodySizeToStore` | bytes | `MaxBodySizeToStore`, SQL Server and PostgreSQL only | 6.20.0 |
| `Storage.Schema` | `Default`, `Custom` | `Database/Schema`, SQL Server and PostgreSQL only | Unreleased |
| `Storage.Schema` | `Default` when the schema is `sc`, `Custom` for other configured schemas | `Database/Schema`, SQL Server and PostgreSQL only | Unreleased |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will also need to update the docs PR

Comment thread src/ServiceControl.Audit.Persistence.EFCore/DbContexts/AuditDbContext.cs Outdated
Comment thread src/ServiceControl.Persistence.EFCore.SqlServer/SqlServerDatabaseMigrator.cs Outdated
@rbev
rbev requested a review from warwickschroeder October 23, 2026 05:31
@johnsimons

Copy link
Copy Markdown
Member

Shouldn't this be up to the user to decide?
What exactly is the problem here? As far as I know, there are no sharing of tables.

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.

4 participants