Skip to content

Commit 792740e

Browse files
benitavRentacookie
andauthored
SQL Server (alpha) support (#296)
* Add references (with placeholder) * Scripts from self-host-example * Additional reading links * Limitations placeholder * Simplify * cleanup * update diagram * Don't need to mention Azure SQL explicitly * Added SQLServer <-> SQLite type mapping * Small fixes * Updated database setup instructions for SQL Server * Tweak mssql database-setup instructions. * Reworked mssql database setup instructions * Next channel * Update feature status * Additional details and limitations section added for sql server * service version * service version * v1.18.1 instead * update self-host-architecture-diagram * add demo app for mssql * format node-mssql * Restructured limitations * Some more tweaks to scripts * Apply suggestion from @benitav * Apply suggestion from @benitav --------- Co-authored-by: Roland Teichert <roland@journeyapps.com>
1 parent 734e7d2 commit 792740e

21 files changed

+364
-79
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ We use the following icons for supported backend databases and SDKs:
6464
- Postgres: `icon="elephant"`
6565
- MongoDB: `icon="leaf"`
6666
- MySQL: `icon="dolphin"`
67+
- SQL Server: `icon="server"`
6768
- Flutter: `icon="flutter"`
6869
- React Native: `icon="react"`
6970
- Web: `icon="js"`

architecture/architecture-overview.mdx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,23 @@ description: "The core components of PowerSync are the service and client SDKs"
1010
The [PowerSync Service](/architecture/powersync-service) and client SDK operate in unison to keep client-side SQLite databases in sync with a backend database. Learn about their architecture:
1111

1212
<CardGroup cols="2">
13-
<Card title="PowerSync Service" icon="server" horizontal href="/architecture/powersync-service">
14-
15-
</Card>
16-
<Card title="Client Architecture" icon="microchip" horizontal href="/architecture/client-architecture">
17-
18-
</Card>
13+
<Card title="PowerSync Service" icon="server" horizontal href="/architecture/powersync-service" />
14+
<Card title="Client Architecture" icon="microchip" horizontal href="/architecture/client-architecture" />
1915
</CardGroup>
2016

2117
### Protocol
2218

2319
Learn about the sync protocol used between PowerSync clients and a [PowerSync Service](/architecture/powersync-service):
2420

2521
<CardGroup cols="2">
26-
<Card title="PowerSync Protocol" icon="network-wired" horizontal href="/architecture/powersync-protocol">
27-
28-
</Card>
29-
<Card title="Consistency" icon="scale-balanced" horizontal href="/architecture/consistency">
30-
31-
</Card>
22+
<Card title="PowerSync Protocol" icon="network-wired" horizontal href="/architecture/powersync-protocol" />
23+
<Card title="Consistency" icon="scale-balanced" horizontal href="/architecture/consistency" />
3224
</CardGroup>
3325

3426
### Self-Hosted Architecture
3527

3628
For more details on typical architecture of a production self-hosted deployment, see here:
3729

3830
<CardGroup cols="2">
39-
<Card title="Installation" icon="download" horizontal href="/self-hosting/installation">
40-
41-
</Card>
31+
<Card title="Installation" icon="download" horizontal href="/self-hosting/installation" />
4232
</CardGroup>

architecture/powersync-protocol.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ Write checkpoints are used to ensure clients have synced their own changes back
6767

6868
Creating a write checkpoint is a separate operation, which is performed by the client after all data has been uploaded. It is important that this happens after the data has been written to the backend source database.
6969

70-
The server then keeps track of the current CDC stream position on the database (LSN in Postgres, resume token in MongoDB, or GTID + Binlog Position in MySQL), and notifies the client when the data has been replicated, as part of checkpoint data in the normal data stream.
70+
The server then keeps track of the current CDC stream position on the database (LSN in Postgres and SQL Server, resume token in MongoDB and GTID+Binlog Position in MySQL), and notifies the client when the data has been replicated, as part of checkpoint data in the normal data stream.
2.47 KB
Loading
-61.3 KB
Loading

installation/app-backend-setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PowerSync generally assumes that you have some kind of "backend application" as
77

88
When you integrate PowerSync into your app project, PowerSync relies on that "backend application" for a few purposes:
99

10-
1. **Allowing client-side write operations to be uploaded** and [applied](/installation/app-backend-setup/writing-client-changes) to the backend database (Postgres, MongoDB or MySQL). When you write to the client-side SQLite database provided by PowerSync, those writes are also placed into an upload queue. The PowerSync Client SDK manages uploading of those writes to your backend using the `uploadData()` function that you defined in the [Client-Side Setup](/installation/client-side-setup/integrating-with-your-backend) part of the implementation. That `uploadData()` function should call your backend application API to apply the writes to your backend database. The reason why we designed PowerSync this way is to give you full control over things like data validation and authorization of writes, while PowerSync itself requires minimal permissions.
10+
1. **Allowing client-side write operations to be uploaded** and [applied](/installation/app-backend-setup/writing-client-changes) to the backend database (Postgres, MongoDB, MySQL, or SQL Server). When you write to the client-side SQLite database provided by PowerSync, those writes are also placed into an upload queue. The PowerSync Client SDK manages uploading of those writes to your backend using the `uploadData()` function that you defined in the [Client-Side Setup](/installation/client-side-setup/integrating-with-your-backend) part of the implementation. That `uploadData()` function should call your backend application API to apply the writes to your backend database. The reason why we designed PowerSync this way is to give you full control over things like data validation and authorization of writes, while PowerSync itself requires minimal permissions.
1111
2. **Authentication integration:** Your backend is responsible for securely generating the [JWTs](/installation/authentication-setup) used by the PowerSync Client SDK to authenticate with the [PowerSync Service](/architecture/powersync-service).
1212

1313
<Frame caption="An overview of how PowerSync interacts with your backend application.">

installation/app-backend-setup/writing-client-changes.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Since you get to define the client-side `uploadData()` function as you wish, you
1717
You can also use any API style you want — e.g. REST, GraphQL, gRPC, etc.
1818

1919
<Warning>
20-
It's important that your API endpoint be blocking/synchronous with underlying writes to the backend database (Postgres, MongoDB or MySQL).
20+
It's important that your API endpoint be blocking/synchronous with underlying writes to the backend database (Postgres, MongoDB, MySQL, or SQL Server).
2121

2222
In other words, don't place writes into something like a queue for processing later — process them immediately. For more details, see the explainer below.
2323
</Warning>
2424

2525
<Accordion title="Why must my write endpoint be synchronous?">
26-
PowerSync uses a server-authoritative architecture with a checkpoint system for conflict resolution and [consistency](/architecture/consistency). The client advances to a new write checkpoint after uploads have been processed, so if the client believes that the server has written changes into your backend database (Postgres, MongoDB or MySQL), but the next checkpoint does not contain your uploaded changes, those changes will be removed from the client. This could manifest as UI glitches for your end-users, where the changes disappear from the device for a few seconds and then re-appear.
26+
PowerSync uses a server-authoritative architecture with a checkpoint system for conflict resolution and [consistency](/architecture/consistency). The client advances to a new write checkpoint after uploads have been processed, so if the client believes that the server has written changes into your backend database (Postgres, MongoDB, MySQL, or SQL Server), but the next checkpoint does not contain your uploaded changes, those changes will be removed from the client. This could manifest as UI glitches for your end-users, where the changes disappear from the device for a few seconds and then re-appear.
2727
</Accordion>
2828

2929
### Write operations recorded on the client

installation/client-side-setup/integrating-with-your-backend.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ After you've [instantiated](/installation/client-side-setup/instantiate-powersyn
77

88
| Purpose | Description |
99
|---------|-------------|
10-
| **Uploading writes to your backend:** | Writes that are made to the client-side SQLite database are uploaded to your backend application, where you control how they're applied to your backend database (Postgres, MongoDB or MySQL). This is how PowerSync achieves bi-directional syncing of data. |
10+
| **Uploading writes to your backend:** | Writes that are made to the client-side SQLite database are uploaded to your backend application, where you control how they're applied to your backend database (Postgres, MongoDB, MySQL, or SQL Server). This is how PowerSync achieves bi-directional syncing of data. |
1111
| **Authentication integration:** | PowerSync uses JWTs for authentication between the Client SDK and PowerSync Service. Your backend application should be able to generate JWTs that the PowerSync Client SDK can retrieve and use for authentication against your [PowerSync Service](/architecture/powersync-service) instance. |
1212

1313
Accordingly, you must pass a _backend connector_ as an argument when you call `connect()` on the client-side PowerSync database. You must define that backend connector, and it must implement two functions/methods:

installation/database-connection.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,30 @@ For other providers and self-hosted databases:
228228
Make sure that your MySQL database allows access to PowerSync's IPs — see [Security and IP Filtering](/installation/database-setup/security-and-ip-filtering)
229229
</Info>
230230

231+
## <Icon icon="server" iconType="solid" size={32}/> SQL Server (Alpha) Specifics
232+
233+
<Check>
234+
SQL Server support was introduced in version 1.18.1 of the PowerSync Service, which is currently available in the [**Next** channel](resources/feature-status#powersync-cloud).
235+
</Check>
236+
237+
1. In the [PowerSync Dashboard](https://dashboard.powersync.com/), select your project and instance and go to the **Database Connections** view.
238+
2. Click **Connect to Source Database** and ensure the **"SQL Server"** tab is selected.
239+
3. Fill in your SQL Server connection details:
240+
1. "**Name**", "**Host**", "**Port**", "**Database name**", "**Username**", "**Password**" are required.
241+
2. "**Name**" can be any name for the connection.
242+
3. "**Host**" is the endpoint for your SQL Server instance.
243+
4. "**Port**" is typically 1433 for SQL Server (default port).
244+
5. "**Database name**" is the database where CDC is enabled.
245+
6. "**Username**" and "**Password**" maps to the database user created in [Source Database Setup](/installation/database-setup#sql-server-alpha) (e.g., `powersync_user`).
246+
4. Click **Test Connection** and fix any errors.
247+
5. Click **Save Connection**.
248+
249+
PowerSync deploys and configures an isolated cloud environment for you, which can take a few minutes to complete.
250+
251+
<Info>
252+
Make sure that your SQL Server database allows access to PowerSync's IPs — see [Security and IP Filtering](/installation/database-setup/security-and-ip-filtering)
253+
</Info>
254+
255+
Also see:
256+
- [SQL Server Setup](/installation/database-setup#sql-server-alpha)
257+

0 commit comments

Comments
 (0)