From d3ed24f34f1e321b8dbd2defcb2311af65467fed Mon Sep 17 00:00:00 2001 From: Nityananda Gohain Date: Mon, 29 Jul 2024 21:16:32 +0530 Subject: [PATCH] fix: update logs migrations to remove issues (#346) * fix: update logs migrations to remove issues * fix: add old migration data --- .../logs/migrations/000001_init_db.up.sql | 2 +- .../migrations/000010_body_ngram.down.sql | 6 ++- .../logs/migrations/000010_body_ngram.up.sql | 7 +++- .../000011_add_instrumentation_scope.down.sql | 19 +++++----- .../000011_add_instrumentation_scope.up.sql | 37 +++++++++++++------ ...0012_rename_instrumentation_scope.down.sql | 28 ++++++-------- ...000012_rename_instrumentation_scope.up.sql | 29 +++++++-------- ...0013_rename_instrumentation_scope.down.sql | 6 ++- ...000013_rename_instrumentation_scope.up.sql | 7 +++- 9 files changed, 80 insertions(+), 61 deletions(-) diff --git a/migrationmanager/migrators/logs/migrations/000001_init_db.up.sql b/migrationmanager/migrators/logs/migrations/000001_init_db.up.sql index ccb103f5..81e43a16 100644 --- a/migrationmanager/migrators/logs/migrations/000001_init_db.up.sql +++ b/migrationmanager/migrators/logs/migrations/000001_init_db.up.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ( attributes_int64_value Array(Int64) CODEC(ZSTD(1)), attributes_float64_key Array(String) CODEC(ZSTD(1)), attributes_float64_value Array(Float64) CODEC(ZSTD(1)), - INDEX body_idx body TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4 + INDEX body_idx body TYPE ngrambf_v1(4, 60000, 5, 0) GRANULARITY 1 ) ENGINE {{.SIGNOZ_REPLICATED}}MergeTree PARTITION BY toDate(timestamp / 1000000000) ORDER BY (timestamp, id) diff --git a/migrationmanager/migrators/logs/migrations/000010_body_ngram.down.sql b/migrationmanager/migrators/logs/migrations/000010_body_ngram.down.sql index 55e3cb94..a0d21ccb 100644 --- a/migrationmanager/migrators/logs/migrations/000010_body_ngram.down.sql +++ b/migrationmanager/migrators/logs/migrations/000010_body_ngram.down.sql @@ -1,2 +1,4 @@ -ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} DROP INDEX IF EXISTS body_idx; -ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} ADD INDEX IF NOT EXISTS body_idx body TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4; \ No newline at end of file +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} DROP INDEX IF EXISTS body_idx +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} ADD INDEX IF NOT EXISTS body_idx body TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4 + +SELECT 1 \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000010_body_ngram.up.sql b/migrationmanager/migrators/logs/migrations/000010_body_ngram.up.sql index d0bba413..f423dc3a 100644 --- a/migrationmanager/migrators/logs/migrations/000010_body_ngram.up.sql +++ b/migrationmanager/migrators/logs/migrations/000010_body_ngram.up.sql @@ -1,2 +1,5 @@ -ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} DROP INDEX IF EXISTS body_idx ; -ALTER TABLE signoz_logs.logs ON CLUSTER {{ .SIGNOZ_CLUSTER }} ADD INDEX IF NOT EXISTS body_idx lower(body) TYPE ngrambf_v1(4, 60000, 5, 0) GRANULARITY 1; \ No newline at end of file +-- Please run the below commands if you are trying to fix schema migration issue https://signoz.io/docs/userguide/logs_troubleshooting/#schema-migrator-dirty-database-version +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP INDEX IF EXISTS body_idx +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS body_idx lower(body) TYPE ngrambf_v1(4, 60000, 5, 0) GRANULARITY 1SELECT 1 + +SELECT 1 \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.down.sql b/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.down.sql index 807c68a9..ffa0601e 100644 --- a/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.down.sql +++ b/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.down.sql @@ -1,18 +1,19 @@ +-- Please run the below commands if you are trying to fix schema migration issue https://signoz.io/docs/userguide/logs_troubleshooting/#schema-migrator-dirty-database-version ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource') CODEC(ZSTD(1)); ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource') CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP INDEX IF EXISTS instrumentation_scope_idx; +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP INDEX IF EXISTS scope_name_idx; -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope; +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_name; +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_name; -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_version; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_version; +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_version; +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_version; -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_attributes_string_key; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_attributes_string_key; +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_string_key; +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_string_key; -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_attributes_string_value; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS instrumentation_scope_attributes_string_value; \ No newline at end of file +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_string_value; +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} DROP column IF EXISTS scope_string_value; \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.up.sql b/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.up.sql index 81616ef5..2e908e57 100644 --- a/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.up.sql +++ b/migrationmanager/migrators/logs/migrations/000011_add_instrumentation_scope.up.sql @@ -1,18 +1,33 @@ -ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)); +-- Please run the below commands if you are trying to fix schema migration issue https://signoz.io/docs/userguide/logs_troubleshooting/#schema-migrator-dirty-database-version +-- ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope String CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope String CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_version String CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_version String CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_key Array(String) CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_key Array(String) CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_value Array(String) CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_value Array(String) CODEC(ZSTD(1)) +-- ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS instrumentation_scope_idx (instrumentation_scope) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4 -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope String CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope String CODEC(ZSTD(1)); +-- Don't run the commands below +ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_version String CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_version String CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_key Array(String) CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_key Array(String) CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_name String CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_name String CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_value Array(String) CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS instrumentation_scope_attributes_string_value Array(String) CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_version String CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_version String CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_string_key Array(String) CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_string_key Array(String) CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS instrumentation_scope_idx (instrumentation_scope) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4; \ No newline at end of file +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_string_value Array(String) CODEC(ZSTD(1)); +ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD column IF NOT EXISTS scope_string_value Array(String) CODEC(ZSTD(1)); + + +ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS scope_name_idx (scope_name) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4; \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.down.sql b/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.down.sql index a5703b04..184707ad 100644 --- a/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.down.sql +++ b/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.down.sql @@ -1,16 +1,12 @@ -ALTER TABLE signoz_logs.logs DROP INDEX IF EXISTS scope_name_idx; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_name to instrumentation_scope; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_name to instrumentation_scope; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_version to instrumentation_scope_version; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_version to instrumentation_scope_version; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_key to instrumentation_scope_attributes_string_key; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_key to instrumentation_scope_attributes_string_key; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_value to instrumentation_scope_attributes_string_value; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_value to instrumentation_scope_attributes_string_value; - - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS instrumentation_scope_idx (instrumentation_scope) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4; \ No newline at end of file +--ALTER TABLE signoz_logs.logs DROP INDEX IF EXISTS scope_name_idx +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_name to instrumentation_scope +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_name to instrumentation_scope +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_version to instrumentation_scope_version +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_version to instrumentation_scope_version +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_key to instrumentation_scope_attributes_string_key +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_key to instrumentation_scope_attributes_string_key +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_value to instrumentation_scope_attributes_string_value +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS scope_string_value to instrumentation_scope_attributes_string_value +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS instrumentation_scope_idx (instrumentation_scope) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4 + +SELECT 1 \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.up.sql b/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.up.sql index 273f9b88..e7fef808 100644 --- a/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.up.sql +++ b/migrationmanager/migrators/logs/migrations/000012_rename_instrumentation_scope.up.sql @@ -1,16 +1,13 @@ -ALTER TABLE signoz_logs.logs DROP INDEX IF EXISTS instrumentation_scope_idx; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope to scope_name; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope to scope_name; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_version to scope_version; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_version to scope_version; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_key to scope_string_key; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_key to scope_string_key; - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_value to scope_string_value; -ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_value to scope_string_value; - - -ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS scope_name_idx (scope_name) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4; \ No newline at end of file +-- Please run the below commands if you are trying to fix schema migration issue https://signoz.io/docs/userguide/logs_troubleshooting/#schema-migrator-dirty-database-version +--ALTER TABLE signoz_logs.logs DROP INDEX IF EXISTS instrumentation_scope_idx +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope to scope_name +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope to scope_name +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_version to scope_version +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_version to scope_version +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_key to scope_string_key +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_key to scope_string_key +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_value to scope_string_value +--ALTER TABLE signoz_logs.distributed_logs ON CLUSTER {{.SIGNOZ_CLUSTER}} RENAME column IF EXISTS instrumentation_scope_attributes_string_value to scope_string_value +--ALTER TABLE signoz_logs.logs ON CLUSTER {{.SIGNOZ_CLUSTER}} ADD INDEX IF NOT EXISTS scope_name_idx (scope_name) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4 + +SELECT 1 \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.down.sql b/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.down.sql index 1715e13d..7225156b 100644 --- a/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.down.sql +++ b/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.down.sql @@ -1,2 +1,4 @@ -ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)); +--ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)) +--ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'instrumentation_scope') CODEC(ZSTD(1)) + +SELECT 1 \ No newline at end of file diff --git a/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.up.sql b/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.up.sql index 26e9f49b..a22a2392 100644 --- a/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.up.sql +++ b/migrationmanager/migrators/logs/migrations/000013_rename_instrumentation_scope.up.sql @@ -1,2 +1,5 @@ -ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)); -ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)); \ No newline at end of file +-- Please run the below commands if you are trying to fix schema migration issue https://signoz.io/docs/userguide/logs_troubleshooting/#schema-migrator-dirty-database-version +--ALTER TABLE signoz_logs.tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)) +--ALTER TABLE signoz_logs.distributed_tag_attributes ON CLUSTER {{.SIGNOZ_CLUSTER}} modify column tagType Enum8('tag', 'resource', 'scope') CODEC(ZSTD(1)) + +SELECT 1 \ No newline at end of file