Skip to content

feat: Add database scope for table-backed models - #4915

Closed
marcelomendoncasoares with Copilot wants to merge 2 commits into
mainfrom
copilot/add-database-keyword-for-tables
Closed

marcelomendoncasoares with Copilot wants to merge 2 commits into
mainfrom
copilot/add-database-keyword-for-tables

Conversation

Copilot AI commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds class-level database support for table-backed models so repositories and table helpers can be generated for the server, the client, or both.

This PR implements the issue to allow specifying client-side tables on models by:

  • adding support for database: server, database: client, and database: all on models with table
  • preserving the existing default behavior when database is omitted by generating database code only on the server
  • generating client-side table, repository, and protocol support through serverpod_database for models targeting the client
  • excluding database: client tables from server migration definitions
  • enforcing the current SQLite-compatible restriction for client-targeted tables by only allowing btree indexes
  • renaming the database-aware serialization manager to DatabaseSerializationManager while keeping a deprecated compatibility alias for SerializationManagerServer

Targeted analyzer and generator tests were added and updated to cover parsing, validation, server/client generation, and protocol behavior.

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

No breaking changes are intended. SerializationManagerServer now has the agnostic name DatabaseSerializationManager, and a deprecated type alias is kept for backwards compatibility.

@marcelomendoncasoares

This comment was marked as resolved.

@marcelomendoncasoares

This comment was marked as resolved.

Copilot AI commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Try again

Addressed in 2fa4dbe. The change now adds class-level database parsing/validation, limits server database definitions to server/all tables, generates client-side table/repository/protocol support for client/all tables via serverpod_database, and keeps the serialization manager rename backward compatible.

Copilot AI changed the title [WIP] Add database keyword to specify table location for models feat: Add database scope for table-backed models Apr 2, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
@marcelomendoncasoares
marcelomendoncasoares deleted the copilot/add-database-keyword-for-tables branch May 1, 2026 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow specifying client-side tables on models

2 participants