Skip to content

Commit

Permalink
refactor: update compose sql
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Jun 21, 2024
1 parent a844d2b commit 4845ca5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/compose-postgres/categraf/conf/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions docker/initsql/a-n9e.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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''',
Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions docker/migratesql/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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''',
Expand All @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions models/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'"`
}

0 comments on commit 4845ca5

Please sign in to comment.