You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add support for UUID primary keys in PG (#3)
* Fix for PG UUID used as PK
* build(postgres): update test target for the current test files
* docs(docs/postgresql/CLIENT.md): clarify primary key requirements for PostgreSQL and SQLite, added support for UUID primary keys
* test(claude): add custom command for claude code to run sqlite-to-pg tests for the specified table schema
---------
Co-authored-by: Marco Bambini <marco@creolabs.com>
Execute a full roundtrip sync test between a local SQLite database and the local Supabase Docker PostgreSQL instance.
4
+
5
+
## Prerequisites
6
+
- Supabase Docker container running (PostgreSQL on port 54322)
7
+
- HTTP sync server running on http://localhost:8091/postgres
8
+
- Built cloudsync extension (`make` to build `dist/cloudsync.dylib`)
9
+
10
+
## Test Procedure
11
+
12
+
### Step 1: Get DDL from User
13
+
14
+
Ask the user to provide a DDL query for the table(s) to test. It can be in PostgreSQL or SQLite format. Offer the following options:
15
+
16
+
**Option 1: Simple TEXT primary key**
17
+
```sql
18
+
CREATETABLEtest_sync (
19
+
id TEXTPRIMARY KEYNOT NULL,
20
+
name TEXT,
21
+
value INTEGER
22
+
);
23
+
```
24
+
25
+
**Option 2: UUID primary key**
26
+
```sql
27
+
CREATETABLEtest_uuid (
28
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
29
+
name TEXT,
30
+
created_at TIMESTAMPTZ DEFAULT NOW()
31
+
);
32
+
```
33
+
34
+
**Option 3: Two tables scenario (tests multi-table sync)**
35
+
```sql
36
+
CREATETABLEauthors (
37
+
id TEXTPRIMARY KEYNOT NULL,
38
+
name TEXT,
39
+
email TEXT
40
+
);
41
+
42
+
CREATETABLEbooks (
43
+
id TEXTPRIMARY KEYNOT NULL,
44
+
title TEXT,
45
+
author_id TEXT,
46
+
published_year INTEGER
47
+
);
48
+
```
49
+
50
+
**Note:** Avoid INTEGER PRIMARY KEY for sync tests as it is not recommended for distributed sync scenarios (conflicts with auto-increment across devices).
51
+
52
+
### Step 2: Convert DDL
53
+
54
+
Convert the provided DDL to both SQLite and PostgreSQL compatible formats if needed. Key differences:
55
+
- SQLite uses `INTEGER PRIMARY KEY` for auto-increment, PostgreSQL uses `SERIAL` or `BIGSERIAL`
56
+
- SQLite uses `TEXT`, PostgreSQL can use `TEXT` or `VARCHAR`
57
+
- PostgreSQL has more specific types like `TIMESTAMPTZ`, SQLite uses `TEXT` for dates
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude@sqlitecloud.io -password="password" -apikey=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz -auth-url=http://127.0.0.1:54321
65
+
```
66
+
Save the JWT token for later use.
67
+
68
+
### Step 4: Setup PostgreSQL
69
+
70
+
Connect to Supabase PostgreSQL and prepare the environment:
Run the SQLite and PostgreSQL tests for this project.
2
+
3
+
## SQLite Tests
4
+
Run the SQLite extension tests using `make clean && make && make unittest`. This builds the extension and runs all tests including unit tests.
5
+
6
+
## PostgreSQL Tests
7
+
Run the PostgreSQL extension tests using `make postgres-docker-run-test`. This runs `test/postgresql/full_test.sql` against the Docker container.
8
+
9
+
**Note:** PostgreSQL tests require the Docker container to be running. Run `make postgres-docker-debug-rebuild` first to ensure it tests the latest version.
0 commit comments