Skip to content

refactor: Only store column information on SQLite for non-basic types - #4988

Merged
marcelomendoncasoares merged 3 commits into
serverpod:mainfrom
marcelomendoncasoares:reduce-sqlite-schema-table
Apr 22, 2026
Merged

marcelomendoncasoares merged 3 commits into
serverpod:mainfrom
marcelomendoncasoares:reduce-sqlite-schema-table

Conversation

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

The SQLite implementation uses an untracked table (created on the migration file directly) to store additional information about the columns. This is required because SQLite only has 4 basic column types (INTEGER, REAL, TEXT, BLOB) that maps all ColumnTypes.

As a result, each definition.sql and migration.sql end up with a lot of lines just for inserting the column types into the table. This PR reduces the amount of lines by skipping the basic column types (ColumnType.integer/ColumnType.bigint, ColumnType.doublePrecision, ColumnType.bytea, ColumnType.text) that map 1:1 with the SQLite basic types.

The only side-effect of this change is the loss of the int/bigint distinction on SQLite. Most of the reduction on the rows come from skipping the ColumnType.bigint type, since it is the one used for int ID columns. However, since on SQLite it is already the same as int and the migration system already skips migrations between them, this does not really matter.

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

None.

@marcelomendoncasoares
marcelomendoncasoares marked this pull request as ready for review April 22, 2026 18:00
@marcelomendoncasoares
marcelomendoncasoares requested a review from a team April 22, 2026 18:00

@nielsenko nielsenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small and tidy 👍 LGTM

@nielsenko

Copy link
Copy Markdown
Collaborator
image nice

@marcelomendoncasoares
marcelomendoncasoares merged commit b4f9e22 into serverpod:main Apr 22, 2026
79 of 81 checks passed
@marcelomendoncasoares
marcelomendoncasoares deleted the reduce-sqlite-schema-table branch April 22, 2026 19:40
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
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.

2 participants