-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
187 additions
and
129 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
migrations/message_store/00008_updatePrimaryKey_add_col.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ALTER TABLE message RENAME TO message_backup; | ||
|
||
CREATE TABLE IF NOT EXISTS message ( | ||
pubsubTopic BLOB NOT NULL, | ||
contentTopic BLOB NOT NULL, | ||
payload BLOB, | ||
version INTEGER NOT NULL, | ||
timestamp INTEGER NOT NULL, | ||
id BLOB, | ||
messageHash BLOB, -- Newly added, this will be populated with a counter value | ||
storedAt INTEGER NOT NULL, | ||
CONSTRAINT messageIndex PRIMARY KEY (messageHash) | ||
) WITHOUT ROWID; | ||
|
||
|
||
INSERT INTO message(pubsubTopic, contentTopic, payload, version, timestamp, id, messageHash, storedAt) | ||
SELECT | ||
mb.pubsubTopic, | ||
mb.contentTopic, | ||
mb.payload, | ||
mb.version, | ||
mb.timestamp, | ||
mb.id, | ||
randomblob(32), -- to populate 32-byte random blob | ||
mb.storedAt | ||
FROM message_backup AS mb; | ||
|
||
DROP TABLE message_backup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.