Skip to content

Conversation

rkistner
Copy link
Contributor

@rkistner rkistner commented Sep 25, 2024

This changes the schema provided over the API to primarily provide a sqlite type, rather than a postgres type. It's more than just renaming the field - the conversion to the SQLite type now happens in the service (in the specific module), rather than the client.

Each column now primarily has:

  1. sqlite_type: The type as it will behave in sync rules.
  2. internal_type: The original type from the source database. This should not be used to check the type in code, but can be used for descriptions in auto-complete or generated schemas.

The old pg_type and type fields are still kept as is, to preserve backwards-compatibility. However, these do not need to be populated by other modules, and can be removed later.

This now also refactors internals to keep the original type (internal_type) available in the output schema after going through sync rules, allowing us to annotate the generated schema with comments like this:

const assets1 = new Table(
  {
    // id column (text) is automatically included
    name: column.text, // text
    count: column.integer, // int4
    owner_id: column.text // uuid
  },
  { indexes: {} }
);

Copy link

changeset-bot bot commented Sep 25, 2024

🦋 Changeset detected

Latest commit: 4ecaee2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@powersync/service-sync-rules Minor
@powersync/service-jpgwire Patch
@powersync/service-core Patch
@powersync/service-module-postgres Patch
@powersync/service-image Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner merged commit 43a10fa into feat/modular-replication-architecture Sep 26, 2024
9 checks passed
@rkistner rkistner deleted the generic-schema-definitions branch September 26, 2024 07:44
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.

2 participants