Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate vm_messages to hypertable #1149

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions schemas/v1/13_vm_messages_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ func init() {
13,
`
ALTER TABLE {{ .SchemaName | default "public"}}.vm_messages
ADD COLUMN "index" BIGINT NOT NULL,
ADD CONSTRAINT vm_messages_uniq_index UNIQUE (height, state_root, cid, source, index);
ADD COLUMN "index" BIGINT NOT NULL DEFAULT -1;

ALTER TABLE {{ .SchemaName | default "public"}}.vm_messages ALTER COLUMN "index" DROP DEFAULT;
birdychang marked this conversation as resolved.
Show resolved Hide resolved

COMMENT ON COLUMN {{ .SchemaName | default "public"}}.vm_messages.index IS 'Order in which the message was applied.';
`,
Expand Down
21 changes: 21 additions & 0 deletions schemas/v1/14_vm_messages_migration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package v1

func init() {
patches.Register(
14,
`
{{- if and .SchemaName (ne .SchemaName "public") }}
frrist marked this conversation as resolved.
Show resolved Hide resolved
SET search_path TO {{ .SchemaName }},public;
{{- end }}

SELECT create_hypertable(
'vm_messages',
'height',
chunk_time_interval => 2880,
birdychang marked this conversation as resolved.
Show resolved Hide resolved
if_not_exists => TRUE,
migrate_data => TRUE
);
SELECT set_integer_now_func('vm_messages', 'current_height', replace_if_exists => true);
`,
)
}