From 409256c74820e958e6897ff32c7cc79602831c95 Mon Sep 17 00:00:00 2001 From: Daniel Moran Date: Tue, 24 Aug 2021 13:19:27 -0400 Subject: [PATCH] feat: add SQL migration for replication metadata (#22288) --- .../0004_create_replications_table.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sqlite/migrations/0004_create_replications_table.sql diff --git a/sqlite/migrations/0004_create_replications_table.sql b/sqlite/migrations/0004_create_replications_table.sql new file mode 100644 index 0000000000..797af0491f --- /dev/null +++ b/sqlite/migrations/0004_create_replications_table.sql @@ -0,0 +1,25 @@ +-- The user_version should match the "000X" from the file name +-- Ex: 0001_create_notebooks_table should have a user_verison of 1 +PRAGMA user_version=4; + +CREATE TABLE replications +( + id VARCHAR(16) NOT NULL PRIMARY KEY, + org_id VARCHAR(16) NOT NULL, + name TEXT NOT NULL, + description TEXT, + remote_id VARCHAR(16) NOT NULL, + local_bucket_id VARCHAR(16) NOT NULL, + remote_bucket_id VARCHAR(16) NOT NULL, + max_queue_size_bytes INTEGER NOT NULL, + current_queue_size_bytes INTEGER NOT NULL, + latest_response_code INTEGER, + latest_error_message TEXT, + + CONSTRAINT replications_uniq_orgid_name UNIQUE (org_id, name), + FOREIGN KEY (remote_id) REFERENCES remotes(id) ON DELETE CASCADE +); + +-- Create indexes on lookup patterns we expect to be common +CREATE INDEX idx_local_bucket_id_per_org ON replications (org_id, local_bucket_id); +CREATE INDEX idx_remote_id_per_org ON replications (org_id, remote_id);