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
docs: remove NOT NULL requirement from primary key definitions
The extension now enforces NULL primary key rejection at runtime, so
the explicit NOT NULL constraint on PK columns is no longer a schema
requirement. Replace the "must be NOT NULL" guidance with a note about
runtime enforcement.
Copy file name to clipboardExpand all lines: API.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,8 +41,8 @@ This document provides a reference for the SQLite functions provided by the `sql
41
41
42
42
Before initialization, `cloudsync_init` performs schema sanity checks to ensure compatibility with CRDT requirements and best practices. These checks include:
43
43
- Primary keys should not be auto-incrementing integers; GUIDs (UUIDs, ULIDs) are highly recommended to prevent multi-node collisions.
44
-
- All primary key columns must be `NOT NULL`.
45
44
- All non-primary key `NOT NULL` columns must have a `DEFAULT` value.
45
+
-**Note:** Any write operation that includes a NULL value for a primary key column will be rejected with an error, even if SQLite would normally allow it due to a legacy behavior.
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -264,7 +264,7 @@ sqlite3 myapp.db
264
264
265
265
-- Create a table (primary key MUST be TEXT for global uniqueness)
266
266
CREATETABLEIF NOT EXISTS my_data (
267
-
id TEXTPRIMARY KEYNOT NULL,
267
+
id TEXTPRIMARY KEY,
268
268
value TEXTNOT NULL DEFAULT '',
269
269
created_at TEXT DEFAULT CURRENT_TIMESTAMP
270
270
);
@@ -313,7 +313,7 @@ SELECT cloudsync_terminate();
313
313
-- Load extension and create identical table structure
314
314
.load ./cloudsync
315
315
CREATETABLEIF NOT EXISTS my_data (
316
-
id TEXTPRIMARY KEYNOT NULL,
316
+
id TEXTPRIMARY KEY,
317
317
value TEXTNOT NULL DEFAULT '',
318
318
created_at TEXT DEFAULT CURRENT_TIMESTAMP
319
319
);
@@ -372,12 +372,12 @@ When designing your database schema for SQLite Sync, follow these best practices
372
372
-**Use globally unique identifiers**: Always use TEXT primary keys with UUIDs, ULIDs, or similar globally unique identifiers
373
373
-**Avoid auto-incrementing integers**: Integer primary keys can cause conflicts across multiple devices
374
374
-**Use `cloudsync_uuid()`**: The built-in function generates UUIDv7 identifiers optimized for distributed systems
375
-
-**All primary keys must be explicitly declared as `NOT NULL`**.
375
+
-**Note:** Any write operation that includes a NULL value for a primary key column will be rejected with an error, even if SQLite would normally allow it due to a legacy behavior.
376
376
377
377
```sql
378
378
-- ✅ Recommended: Globally unique TEXT primary key
379
379
CREATETABLEusers (
380
-
id TEXTPRIMARY KEYNOT NULL,-- Use cloudsync_uuid()
0 commit comments