The dream journal's table (ADR 0038, D14): `dream`, in the sync engine's
database, a row a dream, its content sealed on the device (key ID,
payload, nonce), so the instance sees only that a dream exists, its size
and when it changed. The same rules as the sittings: the sync engine's
connector refuses a call without a session, each row lives in its
person's space, and deleting the person deletes their dreams with it
(the deletion test now writes and counts a dream too, and leaves
another person's).
The migration `20261103130213716-dreams`:
- `CREATE OR REPLACE FUNCTION gen_random_uuid_v7()`: the generator
repeats the UUID v7 function every migration; replacing it with the
same body changes nothing.
- `CREATE TABLE "dream"`: `id` a UUID v7 by default, `spaceId` the
person's sync space, `keyId` the key it is sealed with, `payload` the
sealed bytes (not null), `nonce` the sealing's nonce.
- `CREATE INDEX "dream_space_idx"` on `spaceId`, so deleting a space
finds its dreams without scanning the table.
- The foreign key from `spaceId` to `offline_sync_spaces("id")` with
`ON DELETE CASCADE`: deleting the space deletes its dreams.
- The version rows of every module in `serverpod_migrations`.
A new, empty table: nothing existing changes and no data moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
94 lines
No EOL
2.6 KiB
JSON
94 lines
No EOL
2.6 KiB
JSON
{
|
|
"__className__": "serverpod.DatabaseMigration",
|
|
"actions": [
|
|
{
|
|
"__className__": "serverpod.DatabaseMigrationAction",
|
|
"type": "createTable",
|
|
"createTable": {
|
|
"__className__": "serverpod.TableDefinition",
|
|
"name": "dream",
|
|
"dartName": "Dream",
|
|
"module": "halkyon_meditate",
|
|
"schema": "public",
|
|
"columns": [
|
|
{
|
|
"__className__": "serverpod.ColumnDefinition",
|
|
"name": "id",
|
|
"fieldName": "id",
|
|
"columnType": 7,
|
|
"isNullable": false,
|
|
"columnDefault": "random_v7",
|
|
"dartType": "UuidValue?"
|
|
},
|
|
{
|
|
"__className__": "serverpod.ColumnDefinition",
|
|
"name": "spaceId",
|
|
"fieldName": "spaceId",
|
|
"columnType": 6,
|
|
"isNullable": true,
|
|
"dartType": "int?"
|
|
},
|
|
{
|
|
"__className__": "serverpod.ColumnDefinition",
|
|
"name": "keyId",
|
|
"fieldName": "keyId",
|
|
"columnType": 0,
|
|
"isNullable": true,
|
|
"dartType": "String?"
|
|
},
|
|
{
|
|
"__className__": "serverpod.ColumnDefinition",
|
|
"name": "payload",
|
|
"fieldName": "payload",
|
|
"columnType": 5,
|
|
"isNullable": false,
|
|
"dartType": "dart:typed_data:ByteData"
|
|
},
|
|
{
|
|
"__className__": "serverpod.ColumnDefinition",
|
|
"name": "nonce",
|
|
"fieldName": "nonce",
|
|
"columnType": 5,
|
|
"isNullable": true,
|
|
"dartType": "dart:typed_data:ByteData?"
|
|
}
|
|
],
|
|
"foreignKeys": [
|
|
{
|
|
"__className__": "serverpod.ForeignKeyDefinition",
|
|
"constraintName": "dream_fk_0",
|
|
"columns": [
|
|
"spaceId"
|
|
],
|
|
"referenceTable": "offline_sync_spaces",
|
|
"referenceTableSchema": "public",
|
|
"referenceColumns": [
|
|
"id"
|
|
],
|
|
"onUpdate": 3,
|
|
"onDelete": 4
|
|
}
|
|
],
|
|
"indexes": [
|
|
{
|
|
"__className__": "serverpod.IndexDefinition",
|
|
"indexName": "dream_space_idx",
|
|
"elements": [
|
|
{
|
|
"__className__": "serverpod.IndexElementDefinition",
|
|
"type": 0,
|
|
"definition": "spaceId"
|
|
}
|
|
],
|
|
"type": "btree",
|
|
"isUnique": false,
|
|
"isPrimary": false
|
|
}
|
|
],
|
|
"managed": true
|
|
}
|
|
}
|
|
],
|
|
"warnings": [],
|
|
"migrationApiVersion": 1
|
|
} |