Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Converting Drizzle tables to Powersync tables #408

Merged
merged 19 commits into from
Dec 2, 2024

Conversation

Chriztiaan
Copy link
Contributor

@Chriztiaan Chriztiaan commented Nov 15, 2024

Description

With the current Drizzle integration users need to maintain two table schema definitions (one for Drizzle and one for PowerSync). The initial idea was to infer a Drizzle schema from the PowerSync schema, but based on feedback and some testing it's clear that a Drizzle schema can be more complex and extensive (for example it supports relations) than a PowerSync schema, so the first stab at having a unified schema definition would be to start from a Drizzle schema.

This PR introduces DrizzleAppSchema and toPowerSyncTable, which allows you to map your Drizzle schema, or tables individually, to a PowerSync AppSchema. The mechanism for defining PowerSync table options are illustrated in the Readme and unit tests. PowerSync table indices can be derived from the Drizzle table indices, so that option is omitted from the options.

Limitations

  • These mapping functions don't support any Drizzle column types beyond text, integer, real.

Copy link

changeset-bot bot commented Nov 15, 2024

🦋 Changeset detected

Latest commit: 3f4f471

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

This PR includes changesets to release 1 package
Name Type
@powersync/drizzle-driver Minor

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

Using getTableConfig instead of iterating keys.
# Conflicts:
#	packages/drizzle-driver/src/index.ts
@Chriztiaan Chriztiaan marked this pull request as ready for review November 20, 2024 17:06
@Chriztiaan Chriztiaan changed the title poc: Converting Drizzle tables to Powersync tables feat: Converting Drizzle tables to Powersync tables Nov 27, 2024
Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

LGTM

@Chriztiaan Chriztiaan merged commit 4a70624 into main Dec 2, 2024
6 checks passed
@Chriztiaan Chriztiaan deleted the feat/drizzle-schema branch December 2, 2024 14:20
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.

3 participants