From 4845ca5bdb7477909a5eea086e41cb3e6f8a4831 Mon Sep 17 00:00:00 2001 From: ning <710leo@gmail.com> Date: Sat, 22 Jun 2024 00:33:45 +0800 Subject: [PATCH] refactor: update compose sql --- docker/compose-postgres/categraf/conf/config.toml | 2 +- .../initsql_for_postgres/a-n9e-for-Postgres.sql | 1 + docker/initsql/a-n9e.sql | 2 ++ docker/migratesql/migrate.sql | 2 ++ models/migrate/migrate.go | 6 ++++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docker/compose-postgres/categraf/conf/config.toml b/docker/compose-postgres/categraf/conf/config.toml index d5ee7c625..7db64dd44 100644 --- a/docker/compose-postgres/categraf/conf/config.toml +++ b/docker/compose-postgres/categraf/conf/config.toml @@ -78,6 +78,6 @@ enable = true ## ibex flush interval interval = "1000ms" ## n9e ibex server rpc address -servers = ["ibex:20090"] +servers = ["nightingale:20090"] ## temp script dir meta_dir = "./meta" diff --git a/docker/compose-postgres/initsql_for_postgres/a-n9e-for-Postgres.sql b/docker/compose-postgres/initsql_for_postgres/a-n9e-for-Postgres.sql index 7c5999f04..01d7b9880 100644 --- a/docker/compose-postgres/initsql_for_postgres/a-n9e-for-Postgres.sql +++ b/docker/compose-postgres/initsql_for_postgres/a-n9e-for-Postgres.sql @@ -870,6 +870,7 @@ CREATE INDEX idx_ident ON builtin_components (ident); CREATE TABLE builtin_payloads ( id BIGSERIAL PRIMARY KEY, type VARCHAR(191) NOT NULL, + uuid BIGINT NOT NULL DEFAULT 0, component VARCHAR(191) NOT NULL, cate VARCHAR(191) NOT NULL, name VARCHAR(191) NOT NULL, diff --git a/docker/initsql/a-n9e.sql b/docker/initsql/a-n9e.sql index ed7f40631..4a33b6d9d 100644 --- a/docker/initsql/a-n9e.sql +++ b/docker/initsql/a-n9e.sql @@ -524,6 +524,7 @@ CREATE TABLE `builtin_components` ( CREATE TABLE `builtin_payloads` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '''unique identifier''', + `uuid` bigint(20) NOT NULL COMMENT '''uuid of payload''', `type` varchar(191) NOT NULL COMMENT '''type of payload''', `component` varchar(191) NOT NULL COMMENT '''component of payload''', `cate` varchar(191) NOT NULL COMMENT '''category of payload''', @@ -538,6 +539,7 @@ CREATE TABLE `builtin_payloads` ( KEY `idx_component` (`component`), KEY `idx_name` (`name`), KEY `idx_cate` (`cate`), + KEY `idx_uuid` (`uuid`), KEY `idx_type` (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/docker/migratesql/migrate.sql b/docker/migratesql/migrate.sql index 0089294a0..eb97f79f1 100644 --- a/docker/migratesql/migrate.sql +++ b/docker/migratesql/migrate.sql @@ -56,6 +56,7 @@ CREATE TABLE `builtin_components` ( CREATE TABLE `builtin_payloads` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '''unique identifier''', + `uuid` bigint(20) NOT NULL COMMENT '''uuid of payload''', `type` varchar(191) NOT NULL COMMENT '''type of payload''', `component` varchar(191) NOT NULL COMMENT '''component of payload''', `cate` varchar(191) NOT NULL COMMENT '''category of payload''', @@ -70,6 +71,7 @@ CREATE TABLE `builtin_payloads` ( KEY `idx_component` (`component`), KEY `idx_name` (`name`), KEY `idx_cate` (`cate`), + KEY `idx_uuid` (`uuid`), KEY `idx_type` (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/models/migrate/migrate.go b/models/migrate/migrate.go index b3c9c574a..8276f69ac 100644 --- a/models/migrate/migrate.go +++ b/models/migrate/migrate.go @@ -66,6 +66,8 @@ func MigrateTables(db *gorm.DB) error { if !db.Migrator().HasTable(&models.BuiltinPayload{}) { dts = append(dts, &models.BuiltinPayload{}) + } else { + dts = append(dts, &BuiltinPayloads{}) } for _, dt := range dts { @@ -248,3 +250,7 @@ type Users struct { type SsoConfig struct { UpdateAt int64 `gorm:"column:update_at;type:int;default:0;comment:update_at"` } + +type BuiltinPayloads struct { + UUID int64 `json:"uuid" gorm:"type:bigint;not null;index:idx_uuid;comment:'uuid of payload'"` +}