Skip to content

Add default schemas that are different for each instance type - #6047

Merged
rbev merged 10 commits into
masterfrom
default-schemas
Oct 27, 2026
Merged

rbev merged 10 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 audit instances to sc_audit. Leave the error instance schema unset so it uses the connection’s default.
  • Preserve explicitly configured Database/Schema values and expose the setting in the error persister manifests.
  • Allow setup to create missing schemas when the connection has permission. Connections without schema-creation permission can use a
    pre-created schema.
  • Add pre-migration checks intended to prevent error and audit instances from sharing a schema.
  • Name the error migrations history table __ErrorMigrationsHistory. Audit continues to use __AuditMigrationsHistory.
  • Document schema selection, creation permissions, and existing-data considerations in docs/sql-persister-schemas.md.

Custom schema names remain supported. Operators must create the schema and grant the configured user rights before running setup if the account does not have access to schema creation.

@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
| Primary (error) | `sc` |
| Audit | `audit` |

* ServiceControl does not create the schema. Create it, and grant the configured user rights on it, before running setup.

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.

I thought we were letting SCMU to at least try create the database and schema?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So it seems that SC will create the schema if it can, I'll update the docs to match what is actually true

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.

It still says it does not create the schema?

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

@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.

@rbev rbev changed the title Add default schemas that are unique Add default schemas that are differnt for each instance type Oct 26, 2026
@rbev rbev changed the title Add default schemas that are differnt for each instance type Add default schemas that are different for each instance type Oct 26, 2026
@rbev

rbev commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

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.

This has now been updated to

  • use default schema from connection for the error instance
  • default the audit to it's own schema and create it if necessary

Comment thread docs/sql-persister-schemas.md Outdated
Comment thread docs/sql-persister-schemas.md Outdated
Comment thread docs/sql-persister-schemas.md Outdated
@rbev
rbev merged commit d419245 into master Oct 27, 2026
36 checks passed
@rbev
rbev deleted the default-schemas branch October 27, 2026 05:40
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