Skip to content

Commit

Permalink
feat(data): record created_at timestamps on parent/child data relatio…
Browse files Browse the repository at this point in the history
…ns PE-3477

created_at is not essential for functionality, but it can be very nice to
have when debugging or writing cleanup/backfill scripts.
  • Loading branch information
djwhitt committed May 5, 2023
1 parent d22229a commit ddba6b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions migrations/2023.04.24T19.18.36.data.nested-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CREATE TABLE IF NOT EXISTS contiguous_data_parents (
hash BLOB NOT NULL,
parent_hash BLOB NOT NULL,
data_offset INTEGER NOT NULL,
created_at INTEGER NOT NULL,
PRIMARY KEY (hash, parent_hash)
);

Expand All @@ -10,5 +11,6 @@ CREATE TABLE IF NOT EXISTS contiguous_data_id_parents (
parent_id BLOB NOT NULL,
data_offset INTEGER NOT NULL,
data_size INTEGER NOT NULL,
created_at INTEGER NOT NULL,
PRIMARY KEY (id, parent_id)
);
6 changes: 4 additions & 2 deletions src/database/sql/data/nested-content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ INSERT OR REPLACE INTO contiguous_data_id_parents (
id,
parent_id,
data_offset,
data_size
data_size,
created_at
) VALUES (
:id,
:parent_id,
:data_offset,
:data_size
:data_size,
:created_at
);
1 change: 1 addition & 0 deletions src/database/standalone-sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ export class StandaloneSqliteDatabaseWorker {
parent_id: fromB64Url(parentId),
data_offset: dataOffset,
data_size: dataSize,
created_at: +(Date.now() / 1000).toFixed(0),
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/data-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ CREATE TABLE contiguous_data_parents (
hash BLOB NOT NULL,
parent_hash BLOB NOT NULL,
data_offset INTEGER NOT NULL,
created_at INTEGER NOT NULL,
PRIMARY KEY (hash, parent_hash)
);
CREATE TABLE contiguous_data_id_parents (
id BLOB NOT NULL,
parent_id BLOB NOT NULL,
data_offset INTEGER NOT NULL,
data_size INTEGER NOT NULL,
created_at INTEGER NOT NULL,
PRIMARY KEY (id, parent_id)
);

0 comments on commit ddba6b2

Please sign in to comment.