From 749c1703a350d0571a8809e1049c132696003a69 Mon Sep 17 00:00:00 2001 From: Kamalesh Palanisamy Date: Wed, 15 Nov 2023 23:01:02 -0500 Subject: [PATCH] Add migrations for shards table in postgres metastore (#4119) --- .../postgresql/12_create-shards.down.sql | 3 +++ .../migrations/postgresql/12_create-shards.up.sql | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.down.sql create mode 100644 quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.up.sql diff --git a/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.down.sql b/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.down.sql new file mode 100644 index 00000000000..6ae7bfc8eb8 --- /dev/null +++ b/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.down.sql @@ -0,0 +1,3 @@ +DROP TABLE shards; + +DROP TYPE IF EXISTS SHARD_STATE; \ No newline at end of file diff --git a/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.up.sql b/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.up.sql new file mode 100644 index 00000000000..5d264aa0e2c --- /dev/null +++ b/quickwit/quickwit-metastore/migrations/postgresql/12_create-shards.up.sql @@ -0,0 +1,14 @@ +CREATE TYPE SHARD_STATE AS ENUM ('unspecified', 'open', 'unavailable', 'closed'); + +CREATE TABLE IF NOT EXISTS shards ( + index_uid VARCHAR(282) NOT NULL, + source_id VARCHAR(255) NOT NULL, + shard_id BIGSERIAL, + leader_id VARCHAR(255) NOT NULL, + follower_id VARCHAR(255), + shard_state SHARD_STATE NOT NULL, + publish_position_inclusive VARCHAR(255) NOT NULL, + publish_token VARCHAR(255), + PRIMARY KEY (index_uid, source_id, shard_id), + FOREIGN KEY (index_uid) REFERENCES indexes (index_uid) +); \ No newline at end of file