Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: reorg tags (#12286)

Danny Xuc929f5df90fb
diff --git a/backend/plugin/advisor/advisor.go b/backend/plugin/advisor/advisor.go
index 382938145c..423a89f43c 100644
--- a/backend/plugin/advisor/advisor.go
+++ b/backend/plugin/advisor/advisor.go
@@ -16,17 +16,7 @@ import (
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
-// Status is the advisor result status.
-type Status string
-
const (
- // Success is the advisor status for successes.
- Success Status = "SUCCESS"
- // Warn is the advisor status for warnings.
- Warn Status = "WARN"
- // Error is the advisor status for errors.
- Error Status = "ERROR"
-
// SyntaxErrorTitle is the error title for syntax error.
SyntaxErrorTitle string = "Syntax error"
)
@@ -42,602 +32,6 @@ func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRuleLevel) (storepb.Ad
return storepb.Advice_STATUS_UNSPECIFIED, errors.Errorf("unexpected rule level type: %s", level)
}
-// GetPriority returns the priority of status.
-func (s Status) GetPriority() int {
- switch s {
- case Success:
- return 0
- case Warn:
- return 1
- case Error:
- return 2
- }
- return 0
-}
-
-// Type is the type of advisor.
-// nolint
-type Type string
-
-const (
- // Fake is a fake advisor type for testing.
- Fake Type = "bb.plugin.advisor.fake"
-
- // MySQL Advisor.
-
- // MySQLSyntax is an advisor type for MySQL syntax.
- MySQLSyntax Type = "bb.plugin.advisor.mysql.syntax"
-
- // MySQLUseInnoDB is an advisor type for MySQL InnoDB Engine.
- MySQLUseInnoDB Type = "bb.plugin.advisor.mysql.use-innodb"
-
- // MySQLOnlineMigration is an advisor type for MySQL using online migration to migrate large tables.
- MySQLOnlineMigration Type = "bb.plugin.advisor.mysql.online-migration"
-
- // MySQLMigrationCompatibility is an advisor type for MySQL migration compatibility.
- MySQLMigrationCompatibility Type = "bb.plugin.advisor.mysql.migration-compatibility"
-
- // MySQLWhereRequirement is an advisor type for MySQL WHERE clause requirement.
- MySQLWhereRequirement Type = "bb.plugin.advisor.mysql.where.require"
-
- // MySQLNoLeadingWildcardLike is an advisor type for MySQL no leading wildcard LIKE.
- MySQLNoLeadingWildcardLike Type = "bb.plugin.advisor.mysql.where.no-leading-wildcard-like"
-
- // MySQLNamingTableConvention is an advisor type for MySQL table naming convention.
- MySQLNamingTableConvention Type = "bb.plugin.advisor.mysql.naming.table"
-
- // MySQLNamingIndexConvention is an advisor type for MySQL index key naming convention.
- MySQLNamingIndexConvention Type = "bb.plugin.advisor.mysql.naming.index"
-
- // MySQLNamingUKConvention is an advisor type for MySQL unique key naming convention.
- MySQLNamingUKConvention Type = "bb.plugin.advisor.mysql.naming.uk"
-
- // MySQLNamingFKConvention is an advisor type for MySQL foreign key naming convention.
- MySQLNamingFKConvention Type = "bb.plugin.advisor.mysql.naming.fk"
-
- // MySQLNamingColumnConvention is an advisor type for MySQL column naming convention.
- MySQLNamingColumnConvention Type = "bb.plugin.advisor.mysql.naming.column"
-
- // MySQLNamingAutoIncrementColumnConvention is an advisor type for MySQL auto-increment naming convention.
- MySQLNamingAutoIncrementColumnConvention Type = "bb.plugin.advisor.mysql.naming.auto-increment-column"
-
- // MySQLIdentifierNamingNoKeyword is an advisor type for MySQL identifier naming convention without keyword.
- MySQLIdentifierNamingNoKeyword Type = "bb.plugin.advisor.mysql.naming.identifier-no-keyword"
-
- // MySQLColumnRequirement is an advisor type for MySQL column requirement.
- MySQLColumnRequirement Type = "bb.plugin.advisor.mysql.column.require"
-
- // MySQLColumnNoNull is an advisor type for MySQL column no NULL value.
- MySQLColumnNoNull Type = "bb.plugin.advisor.mysql.column.no-null"
-
- // MySQLColumnDisallowChangingType is an advisor type for MySQL disallow changing column type.
- MySQLColumnDisallowChangingType Type = "bb.plugin.advisor.mysql.column.disallow-changing-type"
-
- // MySQLColumnSetDefaultForNotNull is an advisor type for MySQL set default value for not null column.
- MySQLColumnSetDefaultForNotNull Type = "bb.plugin.advisor.mysql.column.set-default-for-not-null"
-
- // MySQLColumnDisallowChanging is an advisor type for MySQL disallow CHANGE COLUMN statement.
- MySQLColumnDisallowChanging Type = "bb.plugin.advisor.mysql.column.disallow-change"
-
- // MySQLColumnDisallowDrop is an advisor type for MySQL disallow DROP COLUMN statement.
- MySQLColumnDisallowDrop Type = "bb.plugin.advisor.mysql.column.disallow-drop"
-
- // MySQLColumnDisallowDropInIndex is an advisor type for MySQL disallow DROP COLUMN in index.
- MySQLColumnDisallowDropInIndex Type = "bb.plugin.advisor.mysql.column.disallow-drop-in-index"
-
- // MySQLColumnDisallowChangingOrder is an advisor type for MySQL disallow changing column order.
- MySQLColumnDisallowChangingOrder Type = "bb.plugin.advisor.mysql.column.disallow-changing-order"
-
- // MySQLColumnCommentConvention is an advisor type for MySQL column comment convention.
- MySQLColumnCommentConvention Type = "bb.plugin.advisor.mysql.column.comment"
-
- // MySQLAutoIncrementColumnMustInteger is an advisor type for auto-increment column.
- MySQLAutoIncrementColumnMustInteger Type = "bb.plugin.advisor.mysql.column.auto-increment-must-integer"
-
- // MySQLDisallowSetColumnCharset is an advisor type for MySQL disallow set column charset.
- MySQLDisallowSetColumnCharset Type = "bb.plugin.advisor.mysql.column.disallow-set-charset"
-
- // MySQLColumnTypeDisallowList is an advisor type for MySQL column type disallow list.
- MySQLColumnTypeDisallowList Type = "bb.plugin.advisor.mysql.column.type-disallow-list"
-
- // MySQLColumnMaximumCharacterLength is an advisor type for MySQL maximum character length.
- MySQLColumnMaximumCharacterLength Type = "bb.plugin.advisor.mysql.column.maximum-character-length"
-
- // MySQLColumnMaximumVarcharLength is an advisor type for MySQL maximum varchar length.
- MySQLColumnMaximumVarcharLength Type = "bb.plugin.advisor.mysql.column.maximum-varchar-length"
-
- // MySQLAutoIncrementColumnInitialValue is an advisor type for MySQL auto-increment column initial value.
- MySQLAutoIncrementColumnInitialValue Type = "bb.plugin.advisor.mysql.column.auto-increment-initial-value"
-
- // MySQLAutoIncrementColumnMustUnsigned is an advisor type for MySQL unsigned auto-increment column.
- MySQLAutoIncrementColumnMustUnsigned Type = "bb.plugin.advisor.mysql.column.auto-increment-must-unsigned"
-
- // MySQLCurrentTimeColumnCountLimit is an advisor type for MySQL current time column count limit.
- MySQLCurrentTimeColumnCountLimit Type = "bb.plugin.advisor.mysql.column.current-time-count-limit"
-
- // MySQLRequireColumnDefault is an advisor type for MySQL column default requirement.
- MySQLRequireColumnDefault Type = "bb.plugin.advisor.mysql.column.require-default"
-
- // MySQLNoSelectAll is an advisor type for MySQL no select all.
- MySQLNoSelectAll Type = "bb.plugin.advisor.mysql.select.no-select-all"
-
- // MySQLTableRequirePK is an advisor type for MySQL table require primary key.
- MySQLTableRequirePK Type = "bb.plugin.advisor.mysql.table.require-pk"
-
- // MySQLTableNoFK is an advisor type for MySQL table disallow foreign key.
- MySQLTableNoFK Type = "bb.plugin.advisor.mysql.table.no-foreign-key"
-
- // MySQLTableDropNamingConvention is an advisor type for MySQL table drop with naming convention.
- MySQLTableDropNamingConvention Type = "bb.plugin.advisor.mysql.table.drop-naming-convention"
-
- // MySQLTableCommentConvention is an advisor for MySQL table comment convention.
- MySQLTableCommentConvention Type = "bb.plugin.advisor.mysql.table.comment"
-
- // MySQLTableDisallowPartition is an advisor type for MySQL disallow table partition.
- MySQLTableDisallowPartition Type = "bb.plugin.advisor.mysql.table.disallow-partition"
-
- // MySQLTableDisallowTrigger is an advisor type for MySQL disallow table trigger.
- MySQLTableDisallowTrigger Type = "bb.plugin.advisor.mysql.table.disallow-trigger"
-
- // MySQLTableNoDuplicateIndex is an advisor type for MySQL no duplicate index.
- MySQLTableNoDuplicateIndex Type = "bb.plugin.advisor.mysql.table.no-duplicate-index"
-
- // MySQLTableTextFieldsTotalLength is an advisor type for MySQL table text fields total length.
- MySQLTableTextFieldsTotalLength Type = "bb.plugin.advisor.mysql.table.text-fields-total-length"
-
- // MySQLTableFieldsMaximumCount is an advisor type for MySQL table fields maximum count.
- MySQLTableDisallowSetCharset Type = "bb.plugin.advisor.mysql.table.disallow-set-charset"
-
- // MySQLTableFieldsMaximumCount is an advisor type for limiting MySQL table size.
- MySQLTableLimitSize Type = "bb.plugin.advisor.mysql.table.limit-size"
-
- // MySQLDatabaseAllowDropIfEmpty is an advisor type for MySQL only allow drop empty database.
- MySQLDatabaseAllowDropIfEmpty Type = "bb.plugin.advisor.mysql.database.drop-empty-database"
-
- // MySQLIndexNoDuplicateColumn is an advisor type for MySQL no duplicate columns in index.
- MySQLIndexNoDuplicateColumn Type = "bb.plugin.advisor.mysql.index.no-duplicate-column"
-
- // MySQLIndexPKType is an advisor type for MySQL correct type of PK.
- MySQLIndexPKType Type = "bb.plugin.advisor.mysql.index.pk-type"
-
- // MySQLPrimaryKeyTypeAllowlist is an advisor type for MySQL primary key type allowlist.
- MySQLPrimaryKeyTypeAllowlist Type = "bb.plugin.advisor.mysql.index.primary-key-type-allowlist"
-
- // MySQLIndexKeyNumberLimit is an advisor type for MySQL index key number limit.
- MySQLIndexKeyNumberLimit Type = "bb.plugin.advisor.mysql.index.key-number-limit"
-
- // MySQLIndexTotalNumberLimit is an advisor type for MySQL index total number limit.
- MySQLIndexTotalNumberLimit Type = "bb.plugin.advisor.mysql.index.total-number-limit"
-
- // MySQLIndexTypeAllowList is an advisor type for MySQL index type allowlist.
- MySQLIndexTypeAllowList Type = "bb.plugin.advisor.mysql.index.type-allow-list"
-
- // MySQLCharsetAllowlist is an advisor type for MySQL charset allowlist.
- MySQLCharsetAllowlist Type = "bb.plugin.advisor.mysql.charset.allowlist"
-
- // MySQLCollationAllowlist is an advisor type for MySQL collation allowlist.
- MySQLCollationAllowlist Type = "bb.plugin.advisor.mysql.collation.allowlist"
-
- // MySQLIndexTypeNoBlob is an advisor type for MySQL index type no blob.
- MySQLIndexTypeNoBlob Type = "bb.plugin.advisor.mysql.index.type-no-blob"
-
- // MySQLStatementDisallowCommit is an advisor type for MySQL to disallow commit.
- MySQLStatementDisallowCommit Type = "bb.plugin.advisor.mysql.statement.disallow-commit"
-
- // MySQLStatementDisallowLimit is an advisor type for MySQL no LIMIT clause in INSERT/UPDATE/DELETE statement.
- MySQLStatementDisallowLimit Type = "bb.plugin.advisor.mysql.statement.disallow-limit"
-
- // MySQLStatementDisallowUsingFilesort is an advisor type for MySQL disallow using filesort in execution plan.
- MySQLStatementDisallowUsingFilesort Type = "bb.plugin.advisor.mysql.statement.disallow-using-filesort"
-
- // MySQLStatementDisallowUsingTemporary is an advisor type for MySQL disallow using temporary in execution plan.
- MySQLStatementDisallowUsingTemporary Type = "bb.plugin.advisor.mysql.statement.disallow-using-temporary"
-
- // MySQLInsertRowLimit is an advisor type for MySQL to limit INSERT rows.
- MySQLInsertRowLimit Type = "bb.plugin.advisor.mysql.insert.row-limit"
-
- // MySQLInsertMustSpecifyColumn is an advisor type for MySQL to enforce column specified.
- MySQLInsertMustSpecifyColumn Type = "bb.plugin.advisor.mysql.insert.must-specify-column"
-
- // MySQLInsertDisallowOrderByRand is an advisor type for MySQL to disallow order by rand in INSERT statements.
- MySQLInsertDisallowOrderByRand Type = "bb.plugin.advisor.mysql.insert.disallow-order-by-rand"
-
- // MySQLDisallowOrderBy is an advisor type for MySQL no ORDER BY clause in DELETE/UPDATE statement.
- MySQLDisallowOrderBy Type = "bb.plugin.advisor.mysql.statement.disallow-order-by"
-
- // MySQLMergeAlterTable is an advisor type for MySQL no redundant ALTER TABLE statements.
- MySQLMergeAlterTable Type = "bb.plugin.advisor.mysql.statement.merge-alter-table"
-
- // MySQLStatementAffectedRowLimit is an advisor type for MySQL UPDATE/DELETE affected row limit.
- MySQLStatementAffectedRowLimit Type = "bb.plugin.advisor.mysql.statement.affected-row-limit"
-
- // MySQLStatementDMLDryRun is an advisor type for MySQL DML dry run.
- MySQLStatementDMLDryRun Type = "bb.plugin.advisor.mysql.statement.dml-dry-run"
-
- // MySQLStatementSelectFullTableScan is an advisor type for checking MySQL select full table scan or not.
- MySQLStatementSelectFullTableScan Type = "bb.plugin.advisor.mysql.statement.select-full-table-scan"
-
- // MySQLStatementWhereNoEqualNull is an advisor type for checking MySQL no equal null in WHERE clause.
- MySQLStatementWhereNoEqualNull Type = "bb.plugin.advisor.mysql.statement.where.no-equal-null"
-
- // MySQLStatementWhereDisallowUsingFunction is an advisor type for checking MySQL disallow using function in WHERE clause.
- MySQLStatementWhereDisallowUsingFunction Type = "bb.plugin.advisor.mysql.statement.query.disallow-using-function"
-
- // MySQLStatementQueryMinumumPlanLevel is an advisor type for checking MySQL query minimum plan level.
- MySQLStatementQueryMinumumPlanLevel Type = "bb.plugin.advisor.mysql.statement.query.minimum-plan-level"
-
- // MySQLStatementWhereMaximumLogicalOperatorCount is an advisor type for checking MySQL statement maximum logical operator count in WHERE clause.
- MySQLStatementWhereMaximumLogicalOperatorCount Type = "bb.plugin.advisor.mysql.statement.where.maximum-logical-operator-count"
-
- // MySQLStatementMaximumLimitValue is an advisor type for MySQL statement maximum limit value.
- MySQLStatementMaximumLimitValue Type = "bb.plugin.advisor.mysql.statement.maximum-limit-value"
-
- // MySQLStatementMaximumJoinTableCount is an advisor type for MySQL statement maximum join table count.
- MySQLStatementMaximumJoinTableCount Type = "bb.plugin.advisor.mysql.statement.maximum-join-table-count"
-
- // MySQLStatementMaximumStatementsInTransaction is an advisor type for MySQL maximum statements in transaction.
- MySQLStatementMaximumStatementsInTransaction Type = "bb.plugin.advisor.mysql.statement.maximum-statements-in-transaction"
-
- // MySQLStatementJoinStrictColumnAttrs is an advisor type for MySQL statement strict column attrs(type, charset) in join.
- MySQLStatementJoinStrictColumnAttrs Type = "bb.plugin.advisor.mysql.statement.join-strict-column-attrs"
-
- // MySQLStatementDisallowMixDDLDML is an advisor type for MySQL disallow mix DDL and DML.
- MySQLStatementDisallowMixDDLDML Type = "bb.plugin.advisor.mysql.statement.disallow-mix-ddl-dml"
-
- // MySQLStatementPriorBackupCheck is an advisor type for MySQL prior backup check.
- MySQLStatementPriorBackupCheck Type = "bb.plugin.advisor.mysql.statement.prior-backup-check"
-
- // MySQLStatementAddColumnWithoutPosition is an advisor type for MySQL checking no position in ADD COLUMN clause.
- MySQLStatementAddColumnWithoutPosition Type = "bb.plugin.advisor.mysql.statement.add-column-without-position"
-
- // MySQLProcedureDisallowCreate is an advisor type for MySQL disallow create procedure.
- MySQLProcedureDisallowCreate Type = "bb.plugin.advisor.mysql.procedure.disallow-create"
-
- // MySQLEventDisallowCreate is an advisor type for MySQL disallow create event.
- MySQLEventDisallowCreate Type = "bb.plugin.advisor.mysql.event.disallow-create"
-
- // MySQLViewDisallowCreate is an advisor type for MySQL disallow create view.
- MySQLViewDisallowCreate Type = "bb.plugin.advisor.mysql.view.disallow-create"
-
- // MySQLFunctionDisallowCreate is an advisor type for MySQL disallow create function.
- MySQLFunctionDisallowCreate Type = "bb.plugin.advisor.mysql.function.disallow-create"
-
- // MySQLFunctionDisallowedList is an advisor type for MySQL disallowed function list.
- MySQLFunctionDisallowedList Type = "bb.plugin.advisor.mysql.function.disallowed-list"
-
- // MySQLDisallowOfflineDDL is an advisor type for MySQL disallow Offline DDL.
- MySQLDisallowOfflineDDL Type = "bb.plugin.advisor.mysql.disallow-offline-ddl"
-
- // PostgreSQL Advisor.
-
- // PostgreSQLSyntax is an advisor type for PostgreSQL syntax.
- PostgreSQLSyntax Type = "bb.plugin.advisor.postgresql.syntax"
-
- // PostgreSQLNamingFullyQualifiedObjectName is an advisor type for enforing full qualified object name.
- PostgreSQLNamingFullyQualifiedObjectName Type = "bb.plugin.advisor.postgresql.naming.fully-qualified"
-
- // PostgreSQLNamingTableConvention is an advisor type for PostgreSQL table naming convention.
- PostgreSQLNamingTableConvention Type = "bb.plugin.advisor.postgresql.naming.table"
-
- // PostgreSQLNamingColumnConvention is an advisor type for PostgreSQL column naming convention.
- PostgreSQLNamingColumnConvention Type = "bb.plugin.advisor.postgresql.naming.column"
-
- // PostgreSQLNamingPKConvention is an advisor type for PostgreSQL primary key naming convention.
- PostgreSQLNamingPKConvention Type = "bb.plugin.advisor.postgresql.naming.pk"
-
- // PostgreSQLNamingIndexConvention is an advisor type for PostgreSQL index naming convention.
- PostgreSQLNamingIndexConvention Type = "bb.plugin.advisor.postgresql.naming.index"
-
- // PostgreSQLNamingUKConvention is an advisor type for PostgreSQL unique key naming convention.
- PostgreSQLNamingUKConvention Type = "bb.plugin.advisor.postgresql.naming.uk"
-
- // PostgreSQLNamingFKConvention is an advisor type for PostgreSQL foreign key naming convention.
- PostgreSQLNamingFKConvention Type = "bb.plugin.advisor.postgresql.naming.fk"
-
- // PostgreSQLColumnNoNull is an advisor type for PostgreSQL column no NULL value.
- PostgreSQLColumnNoNull Type = "bb.plugin.advisor.postgresql.column.no-null"
-
- // PostgreSQLColumnRequirement is an advisor type for PostgreSQL column requirement.
- PostgreSQLColumnRequirement Type = "bb.plugin.advisor.postgresql.column.require"
-
- // PostgreSQLCommentConvention is an advisor type for PostgreSQL comment convention.
- PostgreSQLCommentConvention Type = "bb.plugin.advisor.postgresql.comment"
-
- // PostgreSQLTableRequirePK is an advisor type for PostgreSQL table require primary key.
- PostgreSQLTableRequirePK Type = "bb.plugin.advisor.postgresql.table.require-pk"
-
- // PostgreSQLNoLeadingWildcardLike is an advisor type for PostgreSQL no leading wildcard LIKE.
- PostgreSQLNoLeadingWildcardLike Type = "bb.plugin.advisor.postgresql.where.no-leading-wildcard-like"
-
- // PostgreSQLWhereRequirement is an advisor type for PostgreSQL WHERE clause requirement.
- PostgreSQLWhereRequirement Type = "bb.plugin.advisor.postgresql.where.require"
-
- // PostgreSQLNoSelectAll is an advisor type for PostgreSQL no select all.
- PostgreSQLNoSelectAll Type = "bb.plugin.advisor.postgresql.select.no-select-all"
-
- // PostgreSQLMigrationCompatibility is an advisor type for PostgreSQL migration compatibility.
- PostgreSQLMigrationCompatibility Type = "bb.plugin.advisor.postgresql.migration-compatibility"
-
- // PostgreSQLTableNoFK is an advisor type for PostgreSQL table disallow foreign key.
- PostgreSQLTableNoFK Type = "bb.plugin.advisor.postgresql.table.no-foreign-key"
-
- // PostgreSQLTableDisallowPartition is an advisor type for PostgreSQL disallow table partition.
- PostgreSQLTableDisallowPartition Type = "bb.plugin.advisor.postgresql.table.disallow-partition"
-
- // PostgreSQLInsertRowLimit is an advisor type for PostgreSQL to limit INSERT rows.
- PostgreSQLInsertRowLimit Type = "bb.plugin.advisor.postgresql.insert.row-limit"
-
- // PostgreSQLInsertMustSpecifyColumn is an advisor type for PostgreSQL to enforce column specified.
- PostgreSQLInsertMustSpecifyColumn Type = "bb.plugin.advisor.postgresql.insert.must-specify-column"
-
- // PostgreSQLInsertDisallowOrderByRand is an advisor type for PostgreSQL to disallow order by rand in INSERT statements.
- PostgreSQLInsertDisallowOrderByRand Type = "bb.plugin.advisor.postgresql.insert.disallow-order-by-rand"
-
- // PostgreSQLIndexKeyNumberLimit is an advisor type for postgresql index key number limit.
- PostgreSQLIndexKeyNumberLimit Type = "bb.plugin.advisor.postgresql.index.key-number-limit"
-
- // PostgreSQLPrimaryKeyTypeAllowlist is an advisor type for postgresql primary key type allowlist.
- PostgreSQLPrimaryKeyTypeAllowlist Type = "bb.plugin.advisor.postgresql.index.primary-key-type-allowlist"
-
- // PostgreSQLIndexTotalNumberLimit is an advisor type for PostgreSQL index total number limit.
- PostgreSQLIndexTotalNumberLimit Type = "bb.plugin.advisor.postgresql.index.total-number-limit"
-
- // PostgreSQLEncodingAllowlist is an advisor type for PostgreSQL encoding allowlist.
- PostgreSQLEncodingAllowlist Type = "bb.plugin.advisor.postgresql.charset.allowlist"
-
- // PostgreSQLIndexNoDuplicateColumn is an advisor type for Postgresql no duplicate columns in index.
- PostgreSQLIndexNoDuplicateColumn Type = "bb.plugin.advisor.postgresql.index.no-duplicate-column"
-
- // PostgreSQLCreateIndexConcurrently is an advisor type for PostgreSQL to create index concurrently.
- PostgreSQLCreateIndexConcurrently Type = "bb.plugin.advisor.postgresql.index.create-concurrently"
-
- // PostgreSQLColumnTypeDisallowList is an advisor type for Postgresql column type disallow list.
- PostgreSQLColumnTypeDisallowList Type = "bb.plugin.advisor.postgresql.column.type-disallow-list"
-
- // PostgreSQLColumnDisallowChangingType is an advisor type for PostgreSQL disallow changing column type.
- PostgreSQLColumnDisallowChangingType Type = "bb.plugin.advisor.postgresql.column.disallow-changing-type"
-
- // PostgreSQLColumnMaximumCharacterLength is an advisor type for PostgreSQL maximum character length.
- PostgreSQLColumnMaximumCharacterLength Type = "bb.plugin.advisor.postgresql.column.maximum-character-length"
-
- // PostgreSQLRequireColumnDefault is an advisor type for PostgreSQL column default requirement.
- PostgreSQLRequireColumnDefault Type = "bb.plugin.advisor.postgresql.column.require-default"
-
- // PostgreSQLStatementDisallowCommit is an advisor type for PostgreSQL to disallow commit.
- PostgreSQLStatementDisallowCommit Type = "bb.plugin.advisor.postgresql.statement.disallow-commit"
-
- // PostgreSQLStatementDMLDryRun is an advisor type for PostgreSQL DML dry run.
- PostgreSQLStatementDMLDryRun Type = "bb.plugin.advisor.postgresql.statement.dml-dry-run"
-
- // PostgreSQLStatementAffectedRowLimit is an advisor type for PostgreSQL UPDATE/DELETE affected row limit.
- PostgreSQLStatementAffectedRowLimit Type = "bb.plugin.advisor.postgresql.statement.affected-row-limit"
-
- // PostgreSQLMergeAlterTable is an advisor type for PostgreSQL no redundant ALTER TABLE statements.
- PostgreSQLMergeAlterTable Type = "bb.plugin.advisor.postgresql.statement.merge-alter-table"
-
- // PostgreSQLAddCheckNotValid is an advisor type for PostgreSQL to add check not valid.
- PostgreSQLAddCheckNotValid Type = "bb.plugin.advisor.postgresql.statement.add-check-not-valid"
-
- // PostgreSQLAddFKNotValid is a PostgreSQL advisor type requiring add foreign key not valid.
- PostgreSQLAddFKNotValid Type = "bb.plugin.advisor.postgresql.statement.add-foreign-key-not-valid"
-
- // PostgreSQLDisallowAddColumnWithDefault is an advisor type for PostgreSQL to disallow add column with default.
- PostgreSQLDisallowAddColumnWithDefault Type = "bb.plugin.advisor.postgresql.statement.disallow-add-column-with-default"
-
- // PostgreSQLDisallowAddNotNull is an advisor type for PostgreSQl to disallow add not null.
- PostgreSQLDisallowAddNotNull Type = "bb.plugin.advisor.postgresql.statement.disallow-add-not-null"
-
- // PostgreSQLNonTransactional is an advisor type for PostgreSQL to disallow non-transactional statements.
- PostgreSQLNonTransactional Type = "bb.plugin.advisor.postgresql.statement.non-transactional"
-
- // PostgreSQLTableDropNamingConvention is an advisor type for PostgreSQL table drop with naming convention.
- PostgreSQLTableDropNamingConvention Type = "bb.plugin.advisor.postgresql.table.drop-naming-convention"
-
- // PostgreSQLCollationAllowlist is an advisor type for PostgreSQL collation allowlist.
- PostgreSQLCollationAllowlist Type = "bb.plugin.advisor.postgresql.collation.allowlist"
-
- // PostgreSQLStatementDisallowRemoveTblCascade is an advisor type for PostgreSQL to disallow CASCADE when removing a table.
- PostgreSQLStatementDisallowRemoveTblCascade Type = "bb.plugin.advisor.postgresql.statement.disallow-rm-tbl-cascade"
-
- // PostgreSQLStatementDisallowOnDelCascade is an advisor type for PostgreSQL to disallow ON DELETE CASCADE clauses.
- PostgreSQLStatementDisallowOnDelCascade Type = "bb.plugin.advisor.postgresql.statement.disallow-on-del-cascade"
-
- // PostgreSQLStatementCreateSpecifySchema is an advisor type for PostgreSQL to specify schema when creating.
- PostgreSQLStatementCreateSpecifySchema Type = "bb.plugin.advisor.postgresql.statement.create-specify-schema"
-
- // PostgreSQLStatementCheckSetRoleVariable is an advisor type for PostgreSQL to check set role variable.
- PostgreSQLStatementCheckSetRoleVariable Type = "bb.plugin.advisor.postgresql.statement.check-set-role-variable"
-
- // PostgreSQLStatementDisallowMixDDLDML is an advisor type for PostgreSQL disallow mix DDL and DML.
- PostgreSQLStatementDisallowMixDDLDML Type = "bb.plugin.advisor.postgresql.statement.disallow-mix-ddl-dml"
-
- // PostgreSQLStatementPriorBackupCheck is an advisor type for PostgreSQL do prior backup check.
- PostgreSQLStatementPriorBackupCheck Type = "bb.plugin.advisor.postgresql.statement.prior-backup-check"
-
- // PostgreSQLStatementMaximumLimitValue is an advisor type for PostgreSQL statement maximum limit value.
- PostgreSQLStatementMaximumLimitValue Type = "bb.plugin.advisor.postgresql.statement.maximum-limit-value"
-
- // Oracle Advisor.
-
- // OracleSyntax is an advisor type for Oracle syntax.
- OracleSyntax Type = "bb.plugin.advisor.oracle.syntax"
-
- // OracleTableRequirePK is an advisor type for Oracle table require primary key.
- OracleTableRequirePK Type = "bb.plugin.advisor.oracle.table.require-pk"
-
- // OracleTableNoFK is an advisor type for Oracle table disallow foreign key.
- OracleTableNoFK Type = "bb.plugin.advisor.oracle.table.no-foreign-key"
-
- // OracleNamingTableConvention is an advisor type for Oracle table naming convention.
- OracleNamingTableConvention Type = "bb.plugin.advisor.oracle.naming.table"
-
- // OracleColumnRequirement is an advisor type for Oracle column requirement.
- OracleColumnRequirement Type = "bb.plugin.advisor.oracle.column.require"
-
- // OracleColumnTypeDisallowList is an advisor type for Oracle column type disallow list.
- OracleColumnTypeDisallowList Type = "bb.plugin.advisor.oracle.column.type-disallow-list"
-
- // OracleColumnMaximumCharacterLength is an advisor type for Oracle maximum character length.
- OracleColumnMaximumCharacterLength Type = "bb.plugin.advisor.oracle.column.maximum-character-length"
-
- // OracleColumnMaximumVarcharLength is an advisor type for Oracle maximum varchar length.
- OracleColumnMaximumVarcharLength Type = "bb.plugin.advisor.oracle.column.maximum-varchar-length"
-
- // OracleNoSelectAll is an advisor type for Oracle no select all.
- OracleNoSelectAll Type = "bb.plugin.advisor.oracle.select.no-select-all"
-
- // OracleNoLeadingWildcardLike is an advisor type for Oracle no leading wildcard LIKE.
- OracleNoLeadingWildcardLike Type = "bb.plugin.advisor.oracle.where.no-leading-wildcard-like"
-
- // OracleWhereRequirement is an advisor type for Oracle WHERE clause requirement.
- OracleWhereRequirement Type = "bb.plugin.advisor.oracle.where.require"
-
- // OracleInsertMustSpecifyColumn is an advisor type for Oracle to enforce column specified.
- OracleInsertMustSpecifyColumn Type = "bb.plugin.advisor.oracle.insert.must-specify-column"
-
- // OracleIndexKeyNumberLimit is an advisor type for Oracle index key number limit.
- OracleIndexKeyNumberLimit Type = "bb.plugin.advisor.oracle.index.key-number-limit"
-
- // OracleColumnNoNull is an advisor type for Oracle column no NULL value.
- OracleColumnNoNull Type = "bb.plugin.advisor.oracle.column.no-null"
-
- // OracleRequireColumnDefault is an advisor type for Oracle column default requirement.
- OracleRequireColumnDefault Type = "bb.plugin.advisor.oracle.column.require-default"
-
- // OracleAddNotNullColumnRequireDefault is an advisor type for Oracle adding not null column requires default.
- OracleAddNotNullColumnRequireDefault Type = "bb.plugin.advisor.oracle.column.add-not-null-column-require-default"
-
- // OracleTableNamingNoKeyword is an advisor type for Oracle table naming convention without keyword.
- OracleTableNamingNoKeyword Type = "bb.plugin.advisor.oracle.naming.table-no-keyword"
-
- // OracleIdentifierNamingNoKeyword is an advisor type for Oracle identifier naming convention without keyword.
- OracleIdentifierNamingNoKeyword Type = "bb.plugin.advisor.oracle.naming.identifier-no-keyword"
-
- // OracleIdentifierCase is an advisor type for Oracle identifier case.
- OracleIdentifierCase Type = "bb.plugin.advisor.oracle.naming.identifier-case"
-
- // Snowflake Advisor.
-
- // SnowflakeSyntax is an advisor type for Snowflake syntax.
- SnowflakeSyntax Type = "bb.plugin.advisor.snowflake.syntax"
-
- // SnowflakeNamingTableConvention is an advisor type for Snowflake table naming convention.
- SnowflakeNamingTableConvention Type = "bb.plugin.advisor.snowflake.naming.table"
-
- // SnowflakeTableRequirePK is an advisor type for Snowflake table require primary key.
- SnowflakeTableRequirePK Type = "bb.plugin.advisor.snowflake.table.require-pk"
-
- // SnowflakeTableNoFK is an advisor type for Snowflake table disallow foreign key.
- SnowflakeTableNoFK Type = "bb.plugin.advisor.snowflake.table.no-foreign-key"
-
- // SnowflakeColumnMaximumVarcharLength is an advisor type for Snowflake maximum varchar length.
- SnowflakeColumnMaximumVarcharLength Type = "bb.plugin.advisor.snowflake.column.maximum-varchar-length"
-
- // SnowflakeTableNamingNoKeyword is an advisor type for Snowflake table naming convention without keyword.
- SnowflakeTableNamingNoKeyword Type = "bb.plugin.advisor.snowflake.naming.table-no-keyword"
-
- // SnowflakeWhereRequirement is an advisor type for Snowflake WHERE clause requirement.
- SnowflakeWhereRequirement Type = "bb.plugin.advisor.snowflake.where.require"
-
- // SnowflakeIdentifierNamingNoKeyword is an advisor type for Snowflake identifier naming convention without keyword.
- SnowflakeIdentifierNamingNoKeyword Type = "bb.plugin.advisor.snowflake.naming.identifier-no-keyword"
-
- // SnowflakeColumnRequirement is an advisor type for Snowflake column requirement.
- SnowflakeColumnRequirement Type = "bb.plugin.advisor.snowflake.column.require"
-
- // SnowflakeIdentifierCase is an advisor type for Snowflake identifier case.
- SnowflakeIdentifierCase Type = "bb.plugin.advisor.snowflake.naming.identifier-case"
-
- // SnowflakeColumnNoNull is an advisor type for Snowflake column no NULL value.
- SnowflakeColumnNoNull Type = "bb.plugin.advisor.snowflake.column.no-null"
-
- // SnowflakeNoSelectAll is an advisor type for Snowflake no select all.
- SnowflakeNoSelectAll Type = "bb.plugin.advisor.snowflake.select.no-select-all"
-
- // SnowflakeTableDropNamingConvention is an advisor type for Snowflake table drop with naming convention.
- SnowflakeTableDropNamingConvention Type = "bb.plugin.advisor.snowflake.table.drop-naming-convention"
-
- // SnowflakeMigrationCompatibility is an advisor type for Snowflake migration compatibility.
- SnowflakeMigrationCompatibility Type = "bb.plugin.advisor.snowflake.migration-compatibility"
-
- // MSSQL Advisor.
-
- // MSSQLSyntax is an advisor type for MSSQL syntax.
- MSSQLSyntax Type = "bb.plugin.advisor.mssql.syntax"
-
- // MSSQLNoSelectAll is an advisor type for MSSQL no select all.
- MSSQLNoSelectAll Type = "bb.plugin.advisor.mssql.select.no-select-all"
-
- // MSSQLNamingTableConvention is an advisor type for MSSQL table naming convention.
- MSSQLNamingTableConvention Type = "bb.plugin.advisor.mssql.naming.table"
-
- // MSSQLTableNamingNoKeyword is an advisor type for MSSQL table naming convention without keyword.
- MSSQLTableNamingNoKeyword Type = "bb.plugin.advisor.mssql.naming.table-no-keyword"
-
- // MSSQLIdentifierNamingNoKeyword is an advisor type for MSSQL identifier naming convention without keyword.
- MSSQLIdentifierNamingNoKeyword Type = "bb.plugin.advisor.mssql.naming.identifier-no-keyword"
-
- // MSSQLWhereRequirement is an advisor type for MSSQL WHERE clause requirement.
- MSSQLWhereRequirement Type = "bb.plugin.advisor.mssql.where.require"
-
- // MSSQLColumnMaximumVarcharLength is an advisor type for MSSQL maximum varchar length.
- MSSQLColumnMaximumVarcharLength Type = "bb.plugin.advisor.mssql.column.maximum-varchar-length"
-
- // MSSQLTableDropNamingConvention is an advisor type for MSSQL table drop with naming convention.
- MSSQLTableDropNamingConvention Type = "bb.plugin.advisor.mssql.table.drop-naming-convention"
-
- // MSSQLTableRequirePK is an advisor type for MSSQL table require primary key.
- MSSQLTableRequirePK Type = "bb.plugin.advisor.mssql.table.require-pk"
-
- // MSSQLColumnNoNull is an advisor type for MSSQL column no NULL value.
- MSSQLColumnNoNull Type = "bb.plugin.advisor.mssql.column.no-null"
-
- // MSSQLTableNoFK is an advisor type for MSSQL table disallow foreign key.
- MSSQLTableNoFK Type = "bb.plugin.advisor.mssql.table.no-foreign-key"
-
- // MSSQLMigrationCompatibility is an advisor type for MSSQL migration compatibility.
- MSSQLMigrationCompatibility Type = "bb.plugin.advisor.mssql.migration-compatibility"
-
- // MSSQLColumnRequirement is an advisor type for MSSQL column requirement.
- MSSQLColumnRequirement Type = "bb.plugin.advisor.mssql.column.require"
-
- // MSSQLColumnTypeDisallowList is an advisor type for MSSQL column type disallow list.
- MSSQLColumnTypeDisallowList Type = "bb.plugin.advisor.mssql.column.type-disallow-list"
-
- // MSSQLTableDisallowDDL is an advisor type for MSSQL disallow DDL for specific tables.
- MSSQLTableDisallowDDL = "bb.plugin.advisor.mssql.table.disallow-ddl"
-
- // MSSQLTableDisallowDML is an advisor type for MSSQL disallow DML for specific tables.
- MSSQLTableDisallowDML = "bb.plugin.advisor.mssql.table.disallow-dml"
-
- // MSSQLFuctionDisallowCreate restricts the creation of functions.
- MSSQLFunctionDisallowCreateOrAlter Type = "bb.plugin.advisor.mssql.function.disallow-create-or-alter"
-
- // MSSQLProcedureDisallowCreateOrAlter restricts the creation of procedures.
- MSSQLProcedureDisallowCreateOrAlter Type = "bb.plugin.advisor.mssql.procedure.disallow-create-or-alter"
-
- // MSSQLStatementDisallowCrossDBQueries prohibits cross database queries.
- MSSQLStatementDisallowCrossDBQueries Type = "bb.plugin.advisor.mssql.statement.disallow-cross-db-queries"
-
- // MSSQLStatementWhereDisallowFunctionsAndCalculations prohibit using functions or performing calculation in the where clause.
- MSSQLStatementWhereDisallowFunctionsAndCalculations Type = "bb.plugin.advisor.mssql.statement.disallow-functions-and-calculations"
-
- MSSQLIndexNotRedundant Type = "bb.plugin.advisor.mssql.index.not-redundant"
-)
-
-// Advice is the result of an advisor.
-type Advice struct {
- // Status is the SQL check result. Could be "SUCCESS", "WARN", "ERROR"
- Status Status `json:"status"`
- // Code is the SQL check error code.
- Code Code `json:"code"`
- Title string `json:"title"`
- Content string `json:"content"`
- Line int `json:"line"`
- Column int `json:"column"`
- Details string `json:"details,omitempty"`
-}
-
// SyntaxMode is the type of syntax mode.
type SyntaxMode int
diff --git a/backend/plugin/advisor/code.go b/backend/plugin/advisor/code.go
index 3eb9d19b46..a2eb3934e1 100644
--- a/backend/plugin/advisor/code.go
+++ b/backend/plugin/advisor/code.go
@@ -199,3 +199,570 @@ func (c Code) Int() int {
func (c Code) Int32() int32 {
return int32(c)
}
+
+// Type is the type of advisor.
+// nolint
+type Type string
+
+const (
+ // MySQL Advisor.
+
+ // MySQLSyntax is an advisor type for MySQL syntax.
+ MySQLSyntax Type = "bb.plugin.advisor.mysql.syntax"
+
+ // MySQLUseInnoDB is an advisor type for MySQL InnoDB Engine.
+ MySQLUseInnoDB Type = "bb.plugin.advisor.mysql.use-innodb"
+
+ // MySQLOnlineMigration is an advisor type for MySQL using online migration to migrate large tables.
+ MySQLOnlineMigration Type = "bb.plugin.advisor.mysql.online-migration"
+
+ // MySQLMigrationCompatibility is an advisor type for MySQL migration compatibility.
+ MySQLMigrationCompatibility Type = "bb.plugin.advisor.mysql.migration-compatibility"
+
+ // MySQLWhereRequirement is an advisor type for MySQL WHERE clause requirement.
+ MySQLWhereRequirement Type = "bb.plugin.advisor.mysql.where.require"
+
+ // MySQLNoLeadingWildcardLike is an advisor type for MySQL no leading wildcard LIKE.
+ MySQLNoLeadingWildcardLike Type = "bb.plugin.advisor.mysql.where.no-leading-wildcard-like"
+
+ // MySQLNamingTableConvention is an advisor type for MySQL table naming convention.
+ MySQLNamingTableConvention Type = "bb.plugin.advisor.mysql.naming.table"
+
+ // MySQLNamingIndexConvention is an advisor type for MySQL index key naming convention.
+ MySQLNamingIndexConvention Type = "bb.plugin.advisor.mysql.naming.index"
+
+ // MySQLNamingUKConvention is an advisor type for MySQL unique key naming convention.
+ MySQLNamingUKConvention Type = "bb.plugin.advisor.mysql.naming.uk"
+
+ // MySQLNamingFKConvention is an advisor type for MySQL foreign key naming convention.
+ MySQLNamingFKConvention Type = "bb.plugin.advisor.mysql.naming.fk"
+
+ // MySQLNamingColumnConvention is an advisor type for MySQL column naming convention.
+ MySQLNamingColumnConvention Type = "bb.plugin.advisor.mysql.naming.column"
+
+ // MySQLNamingAutoIncrementColumnConvention is an advisor type for MySQL auto-increment naming convention.
+ MySQLNamingAutoIncrementColumnConvention Type = "bb.plugin.advisor.mysql.naming.auto-increment-column"
+
+ // MySQLIdentifierNamingNoKeyword is an advisor type for MySQL identifier naming convention without keyword.
+ MySQLIdentifierNamingNoKeyword Type = "bb.plugin.advisor.mysql.naming.identifier-no-keyword"
+
+ // MySQLColumnRequirement is an advisor type for MySQL column requirement.
+ MySQLColumnRequirement Type = "bb.plugin.advisor.mysql.column.require"
+
+ // MySQLColumnNoNull is an advisor type for MySQL column no NULL value.
+ MySQLColumnNoNull Type = "bb.plugin.advisor.mysql.column.no-null"
+
+ // MySQLColumnDisallowChangingType is an advisor type for MySQL disallow changing column type.
+ MySQLColumnDisallowChangingType Type = "bb.plugin.advisor.mysql.column.disallow-changing-type"
+
+ // MySQLColumnSetDefaultForNotNull is an advisor type for MySQL set default value for not null column.
+ MySQLColumnSetDefaultForNotNull Type = "bb.plugin.advisor.mysql.column.set-default-for-not-null"
+
+ // MySQLColumnDisallowChanging is an advisor type for MySQL disallow CHANGE COLUMN statement.
+ MySQLColumnDisallowChanging Type = "bb.plugin.advisor.mysql.column.disallow-change"
+
+ // MySQLColumnDisallowDrop is an advisor type for MySQL disallow DROP COLUMN statement.
+ MySQLColumnDisallowDrop Type = "bb.plugin.advisor.mysql.column.disallow-drop"
+
+ // MySQLColumnDisallowDropInIndex is an advisor type for MySQL disallow DROP COLUMN in index.
+ MySQLColumnDisallowDropInIndex Type = "bb.plugin.advisor.mysql.column.disallow-drop-in-index"
+
+ // MySQLColumnDisallowChangingOrder is an advisor type for MySQL disallow changing column order.
+ MySQLColumnDisallowChangingOrder Type = "bb.plugin.advisor.mysql.column.disallow-changing-order"
+
+ // MySQLColumnCommentConvention is an advisor type for MySQL column comment convention.
+ MySQLColumnCommentConvention Type = "bb.plugin.advisor.mysql.column.comment"
+
+ // MySQLAutoIncrementColumnMustInteger is an advisor type for auto-increment column.
+ MySQLAutoIncrementColumnMustInteger Type = "bb.plugin.advisor.mysql.column.auto-increment-must-integer"
+
+ // MySQLDisallowSetColumnCharset is an advisor type for MySQL disallow set column charset.
+ MySQLDisallowSetColumnCharset Type = "bb.plugin.advisor.mysql.column.disallow-set-charset"
+
+ // MySQLColumnTypeDisallowList is an advisor type for MySQL column type disallow list.
+ MySQLColumnTypeDisallowList Type = "bb.plugin.advisor.mysql.column.type-disallow-list"
+
+ // MySQLColumnMaximumCharacterLength is an advisor type for MySQL maximum character length.
+ MySQLColumnMaximumCharacterLength Type = "bb.plugin.advisor.mysql.column.maximum-character-length"
+
+ // MySQLColumnMaximumVarcharLength is an advisor type for MySQL maximum varchar length.
+ MySQLColumnMaximumVarcharLength Type = "bb.plugin.advisor.mysql.column.maximum-varchar-length"
+
+ // MySQLAutoIncrementColumnInitialValue is an advisor type for MySQL auto-increment column initial value.
+ MySQLAutoIncrementColumnInitialValue Type = "bb.plugin.advisor.mysql.column.auto-increment-initial-value"
+
+ // MySQLAutoIncrementColumnMustUnsigned is an advisor type for MySQL unsigned auto-increment column.
+ MySQLAutoIncrementColumnMustUnsigned Type = "bb.plugin.advisor.mysql.column.auto-increment-must-unsigned"
+
+ // MySQLCurrentTimeColumnCountLimit is an advisor type for MySQL current time column count limit.
+ MySQLCurrentTimeColumnCountLimit Type = "bb.plugin.advisor.mysql.column.current-time-count-limit"
+
+ // MySQLRequireColumnDefault is an advisor type for MySQL column default requirement.
+ MySQLRequireColumnDefault Type = "bb.plugin.advisor.mysql.column.require-default"
+
+ // MySQLNoSelectAll is an advisor type for MySQL no select all.
+ MySQLNoSelectAll Type = "bb.plugin.advisor.mysql.select.no-select-all"
+
+ // MySQLTableRequirePK is an advisor type for MySQL table require primary key.
+ MySQLTableRequirePK Type = "bb.plugin.advisor.mysql.table.require-pk"
+
+ // MySQLTableNoFK is an advisor type for MySQL table disallow foreign key.
+ MySQLTableNoFK Type = "bb.plugin.advisor.mysql.table.no-foreign-key"
+
+ // MySQLTableDropNamingConvention is an advisor type for MySQL table drop with naming convention.
+ MySQLTableDropNamingConvention Type = "bb.plugin.advisor.mysql.table.drop-naming-convention"
+
+ // MySQLTableCommentConvention is an advisor for MySQL table comment convention.
+ MySQLTableCommentConvention Type = "bb.plugin.advisor.mysql.table.comment"
+
+ // MySQLTableDisallowPartition is an advisor type for MySQL disallow table partition.
+ MySQLTableDisallowPartition Type = "bb.plugin.advisor.mysql.table.disallow-partition"
+
+ // MySQLTableDisallowTrigger is an advisor type for MySQL disallow table trigger.
+ MySQLTableDisallowTrigger Type = "bb.plugin.advisor.mysql.table.disallow-trigger"
+
+ // MySQLTableNoDuplicateIndex is an advisor type for MySQL no duplicate index.
+ MySQLTableNoDuplicateIndex Type = "bb.plugin.advisor.mysql.table.no-duplicate-index"
+
+ // MySQLTableTextFieldsTotalLength is an advisor type for MySQL table text fields total length.
+ MySQLTableTextFieldsTotalLength Type = "bb.plugin.advisor.mysql.table.text-fields-total-length"
+
+ // MySQLTableFieldsMaximumCount is an advisor type for MySQL table fields maximum count.
+ MySQLTableDisallowSetCharset Type = "bb.plugin.advisor.mysql.table.disallow-set-charset"
+
+ // MySQLTableFieldsMaximumCount is an advisor type for limiting MySQL table size.
+ MySQLTableLimitSize Type = "bb.plugin.advisor.mysql.table.limit-size"
+
+ // MySQLDatabaseAllowDropIfEmpty is an advisor type for MySQL only allow drop empty database.
+ MySQLDatabaseAllowDropIfEmpty Type = "bb.plugin.advisor.mysql.database.drop-empty-database"
+
+ // MySQLIndexNoDuplicateColumn is an advisor type for MySQL no duplicate columns in index.
+ MySQLIndexNoDuplicateColumn Type = "bb.plugin.advisor.mysql.index.no-duplicate-column"
+
+ // MySQLIndexPKType is an advisor type for MySQL correct type of PK.
+ MySQLIndexPKType Type = "bb.plugin.advisor.mysql.index.pk-type"
+
+ // MySQLPrimaryKeyTypeAllowlist is an advisor type for MySQL primary key type allowlist.
+ MySQLPrimaryKeyTypeAllowlist Type = "bb.plugin.advisor.mysql.index.primary-key-type-allowlist"
+
+ // MySQLIndexKeyNumberLimit is an advisor type for MySQL index key number limit.
+ MySQLIndexKeyNumberLimit Type = "bb.plugin.advisor.mysql.index.key-number-limit"
+
+ // MySQLIndexTotalNumberLimit is an advisor type for MySQL index total number limit.
+ MySQLIndexTotalNumberLimit Type = "bb.plugin.advisor.mysql.index.total-number-limit"
+
+ // MySQLIndexTypeAllowList is an advisor type for MySQL index type allowlist.
+ MySQLIndexTypeAllowList Type = "bb.plugin.advisor.mysql.index.type-allow-list"
+
+ // MySQLCharsetAllowlist is an advisor type for MySQL charset allowlist.
+ MySQLCharsetAllowlist Type = "bb.plugin.advisor.mysql.charset.allowlist"
+
+ // MySQLCollationAllowlist is an advisor type for MySQL collation allowlist.
+ MySQLCollationAllowlist Type = "bb.plugin.advisor.mysql.collation.allowlist"
+
+ // MySQLIndexTypeNoBlob is an advisor type for MySQL index type no blob.
+ MySQLIndexTypeNoBlob Type = "bb.plugin.advisor.mysql.index.type-no-blob"
+
+ // MySQLStatementDisallowCommit is an advisor type for MySQL to disallow commit.
+ MySQLStatementDisallowCommit Type = "bb.plugin.advisor.mysql.statement.disallow-commit"
+
+ // MySQLStatementDisallowLimit is an advisor type for MySQL no LIMIT clause in INSERT/UPDATE/DELETE statement.
+ MySQLStatementDisallowLimit Type = "bb.plugin.advisor.mysql.statement.disallow-limit"
+
+ // MySQLStatementDisallowUsingFilesort is an advisor type for MySQL disallow using filesort in execution plan.
+ MySQLStatementDisallowUsingFilesort Type = "bb.plugin.advisor.mysql.statement.disallow-using-filesort"
+
+ // MySQLStatementDisallowUsingTemporary is an advisor type for MySQL disallow using temporary in execution plan.
+ MySQLStatementDisallowUsingTemporary Type = "bb.plugin.advisor.mysql.statement.disallow-using-temporary"
+
+ // MySQLInsertRowLimit is an advisor type for MySQL to limit INSERT rows.
+ MySQLInsertRowLimit Type = "bb.plugin.advisor.mysql.insert.row-limit"
+
+ // MySQLInsertMustSpecifyColumn is an advisor type for MySQL to enforce column specified.
+ MySQLInsertMustSpecifyColumn Type = "bb.plugin.advisor.mysql.insert.must-specify-column"
+
+ // MySQLInsertDisallowOrderByRand is an advisor type for MySQL to disallow order by rand in INSERT statements.
+ MySQLInsertDisallowOrderByRand Type = "bb.plugin.advisor.mysql.insert.disallow-order-by-rand"
+
+ // MySQLDisallowOrderBy is an advisor type for MySQL no ORDER BY clause in DELETE/UPDATE statement.
+ MySQLDisallowOrderBy Type = "bb.plugin.advisor.mysql.statement.disallow-order-by"
+
+ // MySQLMergeAlterTable is an advisor type for MySQL no redundant ALTER TABLE statements.
+ MySQLMergeAlterTable Type = "bb.plugin.advisor.mysql.statement.merge-alter-table"
+
+ // MySQLStatementAffectedRowLimit is an advisor type for MySQL UPDATE/DELETE affected row limit.
+ MySQLStatementAffectedRowLimit Type = "bb.plugin.advisor.mysql.statement.affected-row-limit"
+
+ // MySQLStatementDMLDryRun is an advisor type for MySQL DML dry run.
+ MySQLStatementDMLDryRun Type = "bb.plugin.advisor.mysql.statement.dml-dry-run"
+
+ // MySQLStatementSelectFullTableScan is an advisor type for checking MySQL select full table scan or not.
+ MySQLStatementSelectFullTableScan Type = "bb.plugin.advisor.mysql.statement.select-full-table-scan"
+
+ // MySQLStatementWhereNoEqualNull is an advisor type for checking MySQL no equal null in WHERE clause.
+ MySQLStatementWhereNoEqualNull Type = "bb.plugin.advisor.mysql.statement.where.no-equal-null"
+
+ // MySQLStatementWhereDisallowUsingFunction is an advisor type for checking MySQL disallow using function in WHERE clause.
+ MySQLStatementWhereDisallowUsingFunction Type = "bb.plugin.advisor.mysql.statement.query.disallow-using-function"
+
+ // MySQLStatementQueryMinumumPlanLevel is an advisor type for checking MySQL query minimum plan level.
+ MySQLStatementQueryMinumumPlanLevel Type = "bb.plugin.advisor.mysql.statement.query.minimum-plan-level"
+
+ // MySQLStatementWhereMaximumLogicalOperatorCount is an advisor type for checking MySQL statement maximum logical operator count in WHERE clause.
+ MySQLStatementWhereMaximumLogicalOperatorCount Type = "bb.plugin.advisor.mysql.statement.where.maximum-logical-operator-count"
+
+ // MySQLStatementMaximumLimitValue is an advisor type for MySQL statement maximum limit value.
+ MySQLStatementMaximumLimitValue Type = "bb.plugin.advisor.mysql.statement.maximum-limit-value"
+
+ // MySQLStatementMaximumJoinTableCount is an advisor type for MySQL statement maximum join table count.
+ MySQLStatementMaximumJoinTableCount Type = "bb.plugin.advisor.mysql.statement.maximum-join-table-count"
+
+ // MySQLStatementMaximumStatementsInTransaction is an advisor type for MySQL maximum statements in transaction.
+ MySQLStatementMaximumStatementsInTransaction Type = "bb.plugin.advisor.mysql.statement.maximum-statements-in-transaction"
+
+ // MySQLStatementJoinStrictColumnAttrs is an advisor type for MySQL statement strict column attrs(type, charset) in join.
+ MySQLStatementJoinStrictColumnAttrs Type = "bb.plugin.advisor.mysql.statement.join-strict-column-attrs"
+
+ // MySQLStatementDisallowMixDDLDML is an advisor type for MySQL disallow mix DDL and DML.
+ MySQLStatementDisallowMixDDLDML Type = "bb.plugin.advisor.mysql.statement.disallow-mix-ddl-dml"
+
+ // MySQLStatementPriorBackupCheck is an advisor type for MySQL prior backup check.
+ MySQLStatementPriorBackupCheck Type = "bb.plugin.advisor.mysql.statement.prior-backup-check"
+
+ // MySQLStatementAddColumnWithoutPosition is an advisor type for MySQL checking no position in ADD COLUMN clause.
+ MySQLStatementAddColumnWithoutPosition Type = "bb.plugin.advisor.mysql.statement.add-column-without-position"
+
+ // MySQLProcedureDisallowCreate is an advisor type for MySQL disallow create procedure.
+ MySQLProcedureDisallowCreate Type = "bb.plugin.advisor.mysql.procedure.disallow-create"
+
+ // MySQLEventDisallowCreate is an advisor type for MySQL disallow create event.
+ MySQLEventDisallowCreate Type = "bb.plugin.advisor.mysql.event.disallow-create"
+
+ // MySQLViewDisallowCreate is an advisor type for MySQL disallow create view.
+ MySQLViewDisallowCreate Type = "bb.plugin.advisor.mysql.view.disallow-create"
+
+ // MySQLFunctionDisallowCreate is an advisor type for MySQL disallow create function.
+ MySQLFunctionDisallowCreate Type = "bb.plugin.advisor.mysql.function.disallow-create"
+
+ // MySQLFunctionDisallowedList is an advisor type for MySQL disallowed function list.
+ MySQLFunctionDisallowedList Type = "bb.plugin.advisor.mysql.function.disallowed-list"
+
+ // MySQLDisallowOfflineDDL is an advisor type for MySQL disallow Offline DDL.
+ MySQLDisallowOfflineDDL Type = "bb.plugin.advisor.mysql.disallow-offline-ddl"
+
+ // PostgreSQL Advisor.
+
+ // PostgreSQLSyntax is an advisor type for PostgreSQL syntax.
+ PostgreSQLSyntax Type = "bb.plugin.advisor.postgresql.syntax"
+
+ // PostgreSQLNamingFullyQualifiedObjectName is an advisor type for enforing full qualified object name.
+ PostgreSQLNamingFullyQualifiedObjectName Type = "bb.plugin.advisor.postgresql.naming.fully-qualified"
+
+ // PostgreSQLNamingTableConvention is an advisor type for PostgreSQL table naming convention.
+ PostgreSQLNamingTableConvention Type = "bb.plugin.advisor.postgresql.naming.table"
+
+ // PostgreSQLNamingColumnConvention is an advisor type for PostgreSQL column naming convention.
+ PostgreSQLNamingColumnConvention Type = "bb.plugin.advisor.postgresql.naming.column"
+
+ // PostgreSQLNamingPKConvention is an advisor type for PostgreSQL primary key naming convention.
+ PostgreSQLNamingPKConvention Type = "bb.plugin.advisor.postgresql.naming.pk"
+
+ // PostgreSQLNamingIndexConvention is an advisor type for PostgreSQL index naming convention.
+ PostgreSQLNamingIndexConvention Type = "bb.plugin.advisor.postgresql.naming.index"
+
+ // PostgreSQLNamingUKConvention is an advisor type for PostgreSQL unique key naming convention.
+ PostgreSQLNamingUKConvention Type = "bb.plugin.advisor.postgresql.naming.uk"
+
+ // PostgreSQLNamingFKConvention is an advisor type for PostgreSQL foreign key naming convention.
+ PostgreSQLNamingFKConvention Type = "bb.plugin.advisor.postgresql.naming.fk"
+
+ // PostgreSQLColumnNoNull is an advisor type for PostgreSQL column no NULL value.
+ PostgreSQLColumnNoNull Type = "bb.plugin.advisor.postgresql.column.no-null"
+
+ // PostgreSQLColumnRequirement is an advisor type for PostgreSQL column requirement.
+ PostgreSQLColumnRequirement Type = "bb.plugin.advisor.postgresql.column.require"
+
+ // PostgreSQLCommentConvention is an advisor type for PostgreSQL comment convention.
+ PostgreSQLCommentConvention Type = "bb.plugin.advisor.postgresql.comment"
+
+ // PostgreSQLTableRequirePK is an advisor type for PostgreSQL table require primary key.
+ PostgreSQLTableRequirePK Type = "bb.plugin.advisor.postgresql.table.require-pk"
+
+ // PostgreSQLNoLeadingWildcardLike is an advisor type for PostgreSQL no leading wildcard LIKE.
+ PostgreSQLNoLeadingWildcardLike Type = "bb.plugin.advisor.postgresql.where.no-leading-wildcard-like"
+
+ // PostgreSQLWhereRequirement is an advisor type for PostgreSQL WHERE clause requirement.
+ PostgreSQLWhereRequirement Type = "bb.plugin.advisor.postgresql.where.require"
+
+ // PostgreSQLNoSelectAll is an advisor type for PostgreSQL no select all.
+ PostgreSQLNoSelectAll Type = "bb.plugin.advisor.postgresql.select.no-select-all"
+
+ // PostgreSQLMigrationCompatibility is an advisor type for PostgreSQL migration compatibility.
+ PostgreSQLMigrationCompatibility Type = "bb.plugin.advisor.postgresql.migration-compatibility"
+
+ // PostgreSQLTableNoFK is an advisor type for PostgreSQL table disallow foreign key.
+ PostgreSQLTableNoFK Type = "bb.plugin.advisor.postgresql.table.no-foreign-key"
+
+ // PostgreSQLTableDisallowPartition is an advisor type for PostgreSQL disallow table partition.
+ PostgreSQLTableDisallowPartition Type = "bb.plugin.advisor.postgresql.table.disallow-partition"
+
+ // PostgreSQLInsertRowLimit is an advisor type for PostgreSQL to limit INSERT rows.
+ PostgreSQLInsertRowLimit Type = "bb.plugin.advisor.postgresql.insert.row-limit"
+
+ // PostgreSQLInsertMustSpecifyColumn is an advisor type for PostgreSQL to enforce column specified.
+ PostgreSQLInsertMustSpecifyColumn Type = "bb.plugin.advisor.postgresql.insert.must-specify-column"
+
+ // PostgreSQLInsertDisallowOrderByRand is an advisor type for PostgreSQL to disallow order by rand in INSERT statements.
+ PostgreSQLInsertDisallowOrderByRand Type = "bb.plugin.advisor.postgresql.insert.disallow-order-by-rand"
+
+ // PostgreSQLIndexKeyNumberLimit is an advisor type for postgresql index key number limit.
+ PostgreSQLIndexKeyNumberLimit Type = "bb.plugin.advisor.postgresql.index.key-number-limit"
+
+ // PostgreSQLPrimaryKeyTypeAllowlist is an advisor type for postgresql primary key type allowlist.
+ PostgreSQLPrimaryKeyTypeAllowlist Type = "bb.plugin.advisor.postgresql.index.primary-key-type-allowlist"
+
+ // PostgreSQLIndexTotalNumberLimit is an advisor type for PostgreSQL index total number limit.
+ PostgreSQLIndexTotalNumberLimit Type = "bb.plugin.advisor.postgresql.index.total-number-limit"
+
+ // PostgreSQLEncodingAllowlist is an advisor type for PostgreSQL encoding allowlist.
+ PostgreSQLEncodingAllowlist Type = "bb.plugin.advisor.postgresql.charset.allowlist"
+
+ // PostgreSQLIndexNoDuplicateColumn is an advisor type for Postgresql no duplicate columns in index.
+ PostgreSQLIndexNoDuplicateColumn Type = "bb.plugin.advisor.postgresql.index.no-duplicate-column"
+
+ // PostgreSQLCreateIndexConcurrently is an advisor type for PostgreSQL to create index concurrently.
+ PostgreSQLCreateIndexConcurrently Type = "bb.plugin.advisor.postgresql.index.create-concurrently"
+
+ // PostgreSQLColumnTypeDisallowList is an advisor type for Postgresql column type disallow list.
+ PostgreSQLColumnTypeDisallowList Type = "bb.plugin.advisor.postgresql.column.type-disallow-list"
+
+ // PostgreSQLColumnDisallowChangingType is an advisor type for PostgreSQL disallow changing column type.
+ PostgreSQLColumnDisallowChangingType Type = "bb.plugin.advisor.postgresql.column.disallow-changing-type"
+
+ // PostgreSQLColumnMaximumCharacterLength is an advisor type for PostgreSQL maximum character length.
+ PostgreSQLColumnMaximumCharacterLength Type = "bb.plugin.advisor.postgresql.column.maximum-character-length"
+
+ // PostgreSQLRequireColumnDefault is an advisor type for PostgreSQL column default requirement.
+ PostgreSQLRequireColumnDefault Type = "bb.plugin.advisor.postgresql.column.require-default"
+
+ // PostgreSQLStatementDisallowCommit is an advisor type for PostgreSQL to disallow commit.
+ PostgreSQLStatementDisallowCommit Type = "bb.plugin.advisor.postgresql.statement.disallow-commit"
+
+ // PostgreSQLStatementDMLDryRun is an advisor type for PostgreSQL DML dry run.
+ PostgreSQLStatementDMLDryRun Type = "bb.plugin.advisor.postgresql.statement.dml-dry-run"
+
+ // PostgreSQLStatementAffectedRowLimit is an advisor type for PostgreSQL UPDATE/DELETE affected row limit.
+ PostgreSQLStatementAffectedRowLimit Type = "bb.plugin.advisor.postgresql.statement.affected-row-limit"
+
+ // PostgreSQLMergeAlterTable is an advisor type for PostgreSQL no redundant ALTER TABLE statements.
+ PostgreSQLMergeAlterTable Type = "bb.plugin.advisor.postgresql.statement.merge-alter-table"
+
+ // PostgreSQLAddCheckNotValid is an advisor type for PostgreSQL to add check not valid.
+ PostgreSQLAddCheckNotValid Type = "bb.plugin.advisor.postgresql.statement.add-check-not-valid"
+
+ // PostgreSQLAddFKNotValid is a PostgreSQL advisor type requiring add foreign key not valid.
+ PostgreSQLAddFKNotValid Type = "bb.plugin.advisor.postgresql.statement.add-foreign-key-not-valid"
+
+ // PostgreSQLDisallowAddColumnWithDefault is an advisor type for PostgreSQL to disallow add column with default.
+ PostgreSQLDisallowAddColumnWithDefault Type = "bb.plugin.advisor.postgresql.statement.disallow-add-column-with-default"
+
+ // PostgreSQLDisallowAddNotNull is an advisor type for PostgreSQl to disallow add not null.
+ PostgreSQLDisallowAddNotNull Type = "bb.plugin.advisor.postgresql.statement.disallow-add-not-null"
+
+ // PostgreSQLNonTransactional is an advisor type for PostgreSQL to disallow non-transactional statements.
+ PostgreSQLNonTransactional Type = "bb.plugin.advisor.postgresql.statement.non-transactional"
+
+ // PostgreSQLTableDropNamingConvention is an advisor type for PostgreSQL table drop with naming convention.
+ PostgreSQLTableDropNamingConvention Type = "bb.plugin.advisor.postgresql.table.drop-naming-convention"
+
+ // PostgreSQLCollationAllowlist is an advisor type for PostgreSQL collation allowlist.
+ PostgreSQLCollationAllowlist Type = "bb.plugin.advisor.postgresql.collation.allowlist"
+
+ // PostgreSQLStatementDisallowRemoveTblCascade is an advisor type for PostgreSQL to disallow CASCADE when removing a table.
+ PostgreSQLStatementDisallowRemoveTblCascade Type = "bb.plugin.advisor.postgresql.statement.disallow-rm-tbl-cascade"
+
+ // PostgreSQLStatementDisallowOnDelCascade is an advisor type for PostgreSQL to disallow ON DELETE CASCADE clauses.
+ PostgreSQLStatementDisallowOnDelCascade Type = "bb.plugin.advisor.postgresql.statement.disallow-on-del-cascade"
+
+ // PostgreSQLStatementCreateSpecifySchema is an advisor type for PostgreSQL to specify schema when creating.
+ PostgreSQLStatementCreateSpecifySchema Type = "bb.plugin.advisor.postgresql.statement.create-specify-schema"
+
+ // PostgreSQLStatementCheckSetRoleVariable is an advisor type for PostgreSQL to check set role variable.
+ PostgreSQLStatementCheckSetRoleVariable Type = "bb.plugin.advisor.postgresql.statement.check-set-role-variable"
+
+ // PostgreSQLStatementDisallowMixDDLDML is an advisor type for PostgreSQL disallow mix DDL and DML.
+ PostgreSQLStatementDisallowMixDDLDML Type = "bb.plugin.advisor.postgresql.statement.disallow-mix-ddl-dml"
+
+ // PostgreSQLStatementPriorBackupCheck is an advisor type for PostgreSQL do prior backup check.
+ PostgreSQLStatementPriorBackupCheck Type = "bb.plugin.advisor.postgresql.statement.prior-backup-check"
+
+ // PostgreSQLStatementMaximumLimitValue is an advisor type for PostgreSQL statement maximum limit value.
+ PostgreSQLStatementMaximumLimitValue Type = "bb.plugin.advisor.postgresql.statement.maximum-limit-value"
+
+ // Oracle Advisor.
+
+ // OracleSyntax is an advisor type for Oracle syntax.
+ OracleSyntax Type = "bb.plugin.advisor.oracle.syntax"
+
+ // OracleTableRequirePK is an advisor type for Oracle table require primary key.
+ OracleTableRequirePK Type = "bb.plugin.advisor.oracle.table.require-pk"
+
+ // OracleTableNoFK is an advisor type for Oracle table disallow foreign key.
+ OracleTableNoFK Type = "bb.plugin.advisor.oracle.table.no-foreign-key"
+
+ // OracleNamingTableConvention is an advisor type for Oracle table naming convention.
+ OracleNamingTableConvention Type = "bb.plugin.advisor.oracle.naming.table"
+
+ // OracleColumnRequirement is an advisor type for Oracle column requirement.
+ OracleColumnRequirement Type = "bb.plugin.advisor.oracle.column.require"
+
+ // OracleColumnTypeDisallowList is an advisor type for Oracle column type disallow list.
+ OracleColumnTypeDisallowList Type = "bb.plugin.advisor.oracle.column.type-disallow-list"
+
+ // OracleColumnMaximumCharacterLength is an advisor type for Oracle maximum character length.
+ OracleColumnMaximumCharacterLength Type = "bb.plugin.advisor.oracle.column.maximum-character-length"
+
+ // OracleColumnMaximumVarcharLength is an advisor type for Oracle maximum varchar length.
+ OracleColumnMaximumVarcharLength Type = "bb.plugin.advisor.oracle.column.maximum-varchar-length"
+
+ // OracleNoSelectAll is an advisor type for Oracle no select all.
+ OracleNoSelectAll Type = "bb.plugin.advisor.oracle.select.no-select-all"
+
+ // OracleNoLeadingWildcardLike is an advisor type for Oracle no leading wildcard LIKE.
+ OracleNoLeadingWildcardLike Type = "bb.plugin.advisor.oracle.where.no-leading-wildcard-like"
+
+ // OracleWhereRequirement is an advisor type for Oracle WHERE clause requirement.
+ OracleWhereRequirement Type = "bb.plugin.advisor.oracle.where.require"
+
+ // OracleInsertMustSpecifyColumn is an advisor type for Oracle to enforce column specified.
+ OracleInsertMustSpecifyColumn Type = "bb.plugin.advisor.oracle.insert.must-specify-column"
+
+ // OracleIndexKeyNumberLimit is an advisor type for Oracle index key number limit.
+ OracleIndexKeyNumberLimit Type = "bb.plugin.advisor.oracle.index.key-number-limit"
+
+ // OracleColumnNoNull is an advisor type for Oracle column no NULL value.
+ OracleColumnNoNull Type = "bb.plugin.advisor.oracle.column.no-null"
+
+ // OracleRequireColumnDefault is an advisor type for Oracle column default requirement.
+ OracleRequireColumnDefault Type = "bb.plugin.advisor.oracle.column.require-default"
+
+ // OracleAddNotNullColumnRequireDefault is an advisor type for Oracle adding not null column requires default.
+ OracleAddNotNullColumnRequireDefault Type = "bb.plugin.advisor.oracle.column.add-not-null-column-require-default"
+
+ // OracleTableNamingNoKeyword is an advisor type for Oracle table naming convention without keyword.
+ OracleTableNamingNoKeyword Type = "bb.plugin.advisor.oracle.naming.table-no-keyword"
+
+ // OracleIdentifierNamingNoKeyword is an advisor type for Oracle identifier naming convention without keyword.
+ OracleIdentifierNamingNoKeyword Type = "bb.plugin.advisor.oracle.naming.identifier-no-keyword"
+
+ // OracleIdentifierCase is an advisor type for Oracle identifier case.
+ OracleIdentifierCase Type = "bb.plugin.advisor.oracle.naming.identifier-case"
+
+ // Snowflake Advisor.
+
+ // SnowflakeSyntax is an advisor type for Snowflake syntax.
+ SnowflakeSyntax Type = "bb.plugin.advisor.snowflake.syntax"
+
+ // SnowflakeNamingTableConvention is an advisor type for Snowflake table naming convention.
+ SnowflakeNamingTableConvention Type = "bb.plugin.advisor.snowflake.naming.table"
+
+ // SnowflakeTableRequirePK is an advisor type for Snowflake table require primary key.
+ SnowflakeTableRequirePK Type = "bb.plugin.advisor.snowflake.table.require-pk"
+
+ // SnowflakeTableNoFK is an advisor type for Snowflake table disallow foreign key.
+ SnowflakeTableNoFK Type = "bb.plugin.advisor.snowflake.table.no-foreign-key"
+
+ // SnowflakeColumnMaximumVarcharLength is an advisor type for Snowflake maximum varchar length.
+ SnowflakeColumnMaximumVarcharLength Type = "bb.plugin.advisor.snowflake.column.maximum-varchar-length"
+
+ // SnowflakeTableNamingNoKeyword is an advisor type for Snowflake table naming convention without keyword.
+ SnowflakeTableNamingNoKeyword Type = "bb.plugin.advisor.snowflake.naming.table-no-keyword"
+
+ // SnowflakeWhereRequirement is an advisor type for Snowflake WHERE clause requirement.
+ SnowflakeWhereRequirement Type = "bb.plugin.advisor.snowflake.where.require"
+
+ // SnowflakeIdentifierNamingNoKeyword is an advisor type for Snowflake identifier naming convention without keyword.
+ SnowflakeIdentifierNamingNoKeyword Type = "bb.plugin.advisor.snowflake.naming.identifier-no-keyword"
+
+ // SnowflakeColumnRequirement is an advisor type for Snowflake column requirement.
+ SnowflakeColumnRequirement Type = "bb.plugin.advisor.snowflake.column.require"
+
+ // SnowflakeIdentifierCase is an advisor type for Snowflake identifier case.
+ SnowflakeIdentifierCase Type = "bb.plugin.advisor.snowflake.naming.identifier-case"
+
+ // SnowflakeColumnNoNull is an advisor type for Snowflake column no NULL value.
+ SnowflakeColumnNoNull Type = "bb.plugin.advisor.snowflake.column.no-null"
+
+ // SnowflakeNoSelectAll is an advisor type for Snowflake no select all.
+ SnowflakeNoSelectAll Type = "bb.plugin.advisor.snowflake.select.no-select-all"
+
+ // SnowflakeTableDropNamingConvention is an advisor type for Snowflake table drop with naming convention.
+ SnowflakeTableDropNamingConvention Type = "bb.plugin.advisor.snowflake.table.drop-naming-convention"
+
+ // SnowflakeMigrationCompatibility is an advisor type for Snowflake migration compatibility.
+ SnowflakeMigrationCompatibility Type = "bb.plugin.advisor.snowflake.migration-compatibility"
+
+ // MSSQL Advisor.
+
+ // MSSQLSyntax is an advisor type for MSSQL syntax.
+ MSSQLSyntax Type = "bb.plugin.advisor.mssql.syntax"
+
+ // MSSQLNoSelectAll is an advisor type for MSSQL no select all.
+ MSSQLNoSelectAll Type = "bb.plugin.advisor.mssql.select.no-select-all"
+
+ // MSSQLNamingTableConvention is an advisor type for MSSQL table naming convention.
+ MSSQLNamingTableConvention Type = "bb.plugin.advisor.mssql.naming.table"
+
+ // MSSQLTableNamingNoKeyword is an advisor type for MSSQL table naming convention without keyword.
+ MSSQLTableNamingNoKeyword Type = "bb.plugin.advisor.mssql.naming.table-no-keyword"
+
+ // MSSQLIdentifierNamingNoKeyword is an advisor type for MSSQL identifier naming convention without keyword.
+ MSSQLIdentifierNamingNoKeyword Type = "bb.plugin.advisor.mssql.naming.identifier-no-keyword"
+
+ // MSSQLWhereRequirement is an advisor type for MSSQL WHERE clause requirement.
+ MSSQLWhereRequirement Type = "bb.plugin.advisor.mssql.where.require"
+
+ // MSSQLColumnMaximumVarcharLength is an advisor type for MSSQL maximum varchar length.
+ MSSQLColumnMaximumVarcharLength Type = "bb.plugin.advisor.mssql.column.maximum-varchar-length"
+
+ // MSSQLTableDropNamingConvention is an advisor type for MSSQL table drop with naming convention.
+ MSSQLTableDropNamingConvention Type = "bb.plugin.advisor.mssql.table.drop-naming-convention"
+
+ // MSSQLTableRequirePK is an advisor type for MSSQL table require primary key.
+ MSSQLTableRequirePK Type = "bb.plugin.advisor.mssql.table.require-pk"
+
+ // MSSQLColumnNoNull is an advisor type for MSSQL column no NULL value.
+ MSSQLColumnNoNull Type = "bb.plugin.advisor.mssql.column.no-null"
+
+ // MSSQLTableNoFK is an advisor type for MSSQL table disallow foreign key.
+ MSSQLTableNoFK Type = "bb.plugin.advisor.mssql.table.no-foreign-key"
+
+ // MSSQLMigrationCompatibility is an advisor type for MSSQL migration compatibility.
+ MSSQLMigrationCompatibility Type = "bb.plugin.advisor.mssql.migration-compatibility"
+
+ // MSSQLColumnRequirement is an advisor type for MSSQL column requirement.
+ MSSQLColumnRequirement Type = "bb.plugin.advisor.mssql.column.require"
+
+ // MSSQLColumnTypeDisallowList is an advisor type for MSSQL column type disallow list.
+ MSSQLColumnTypeDisallowList Type = "bb.plugin.advisor.mssql.column.type-disallow-list"
+
+ // MSSQLTableDisallowDDL is an advisor type for MSSQL disallow DDL for specific tables.
+ MSSQLTableDisallowDDL = "bb.plugin.advisor.mssql.table.disallow-ddl"
+
+ // MSSQLTableDisallowDML is an advisor type for MSSQL disallow DML for specific tables.
+ MSSQLTableDisallowDML = "bb.plugin.advisor.mssql.table.disallow-dml"
+
+ // MSSQLFuctionDisallowCreate restricts the creation of functions.
+ MSSQLFunctionDisallowCreateOrAlter Type = "bb.plugin.advisor.mssql.function.disallow-create-or-alter"
+
+ // MSSQLProcedureDisallowCreateOrAlter restricts the creation of procedures.
+ MSSQLProcedureDisallowCreateOrAlter Type = "bb.plugin.advisor.mssql.procedure.disallow-create-or-alter"
+
+ // MSSQLStatementDisallowCrossDBQueries prohibits cross database queries.
+ MSSQLStatementDisallowCrossDBQueries Type = "bb.plugin.advisor.mssql.statement.disallow-cross-db-queries"
+
+ // MSSQLStatementWhereDisallowFunctionsAndCalculations prohibit using functions or performing calculation in the where clause.
+ MSSQLStatementWhereDisallowFunctionsAndCalculations Type = "bb.plugin.advisor.mssql.statement.disallow-functions-and-calculations"
+
+ MSSQLIndexNotRedundant Type = "bb.plugin.advisor.mssql.index.not-redundant"
+)
diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.go
index e9e7b7e4b0..b48b2c7194 100644
--- a/backend/plugin/advisor/sql_review.go
+++ b/backend/plugin/advisor/sql_review.go
@@ -1835,5 +1835,5 @@ func getAdvisorTypeByRule(ruleType SQLReviewRuleType, engine storepb.Engine) (Ty
return MySQLDisallowOfflineDDL, nil
}
}
- return Fake, errors.Errorf("unknown SQL review rule type %v for %v", ruleType, engine)
+ return "", errors.Errorf("unknown SQL review rule type %v for %v", ruleType, engine)
}
diff --git a/backend/server/minimal.go b/backend/server/minimal.go
index 84ce774e3e..e28cb4833c 100644
--- a/backend/server/minimal.go
+++ b/backend/server/minimal.go
@@ -4,12 +4,9 @@ import (
// This includes the first-class database, Postgres.
// Drivers.
- _ "github.com/bytebase/bytebase/backend/plugin/db/dynamodb"
- _ "github.com/bytebase/bytebase/backend/plugin/db/mongodb"
_ "github.com/bytebase/bytebase/backend/plugin/db/pg"
// Parsers.
- _ "github.com/bytebase/bytebase/backend/plugin/parser/partiql"
_ "github.com/bytebase/bytebase/backend/plugin/parser/pg"
// Schema designer.
diff --git a/backend/server/minimal_demo.go b/backend/server/minimal_demo.go
deleted file mode 100644
index aef1a84ba2..0000000000
--- a/backend/server/minimal_demo.go
+++ /dev/null
@@ -1,28 +0,0 @@
-//go:build !minidemo
-
-package server
-
-import (
- // This includes more databases such as MySQL, SQLite, TiDB.
-
- // Drivers.
- _ "github.com/bytebase/bytebase/backend/plugin/db/mysql"
- _ "github.com/bytebase/bytebase/backend/plugin/db/sqlite"
- _ "github.com/bytebase/bytebase/backend/plugin/db/tidb"
-
- // Parsers.
- _ "github.com/bytebase/bytebase/backend/plugin/parser/mysql"
- _ "github.com/bytebase/bytebase/backend/plugin/parser/standard"
- _ "github.com/bytebase/bytebase/backend/plugin/parser/tidb"
-
- // Schema designer.
- _ "github.com/bytebase/bytebase/backend/plugin/schema/mysql"
- _ "github.com/bytebase/bytebase/backend/plugin/schema/tidb"
-
- // Advisors.
- _ "github.com/bytebase/bytebase/backend/plugin/advisor/mysql"
- _ "github.com/bytebase/bytebase/backend/plugin/advisor/tidb"
-
- // Transformers.
- _ "github.com/bytebase/bytebase/backend/plugin/parser/sql/transform/mysql"
-)
diff --git a/backend/server/ultimate.go b/backend/server/ultimate.go
index f5c99495a7..73a0a5e029 100644
--- a/backend/server/ultimate.go
+++ b/backend/server/ultimate.go
@@ -1,4 +1,4 @@
-//go:build !minimal
+//go:build !minidemo
package server
@@ -10,30 +10,42 @@ import (
_ "github.com/bytebase/bytebase/backend/plugin/db/dynamodb"
_ "github.com/bytebase/bytebase/backend/plugin/db/elasticsearch"
_ "github.com/bytebase/bytebase/backend/plugin/db/hive"
+ _ "github.com/bytebase/bytebase/backend/plugin/db/mongodb"
_ "github.com/bytebase/bytebase/backend/plugin/db/mssql"
+ _ "github.com/bytebase/bytebase/backend/plugin/db/mysql"
_ "github.com/bytebase/bytebase/backend/plugin/db/oracle"
_ "github.com/bytebase/bytebase/backend/plugin/db/redis"
_ "github.com/bytebase/bytebase/backend/plugin/db/redshift"
_ "github.com/bytebase/bytebase/backend/plugin/db/risingwave"
_ "github.com/bytebase/bytebase/backend/plugin/db/snowflake"
_ "github.com/bytebase/bytebase/backend/plugin/db/spanner"
+ _ "github.com/bytebase/bytebase/backend/plugin/db/sqlite"
_ "github.com/bytebase/bytebase/backend/plugin/db/starrocks"
+ _ "github.com/bytebase/bytebase/backend/plugin/db/tidb"
// Parsers.
+ _ "github.com/bytebase/bytebase/backend/plugin/parser/mysql"
+ _ "github.com/bytebase/bytebase/backend/plugin/parser/partiql"
_ "github.com/bytebase/bytebase/backend/plugin/parser/plsql"
_ "github.com/bytebase/bytebase/backend/plugin/parser/snowflake"
_ "github.com/bytebase/bytebase/backend/plugin/parser/standard"
+ _ "github.com/bytebase/bytebase/backend/plugin/parser/tidb"
_ "github.com/bytebase/bytebase/backend/plugin/parser/tsql"
// Advisors.
_ "github.com/bytebase/bytebase/backend/plugin/advisor/mssql"
+ _ "github.com/bytebase/bytebase/backend/plugin/advisor/mysql"
_ "github.com/bytebase/bytebase/backend/plugin/advisor/oceanbase"
_ "github.com/bytebase/bytebase/backend/plugin/advisor/oracle"
_ "github.com/bytebase/bytebase/backend/plugin/advisor/snowflake"
+ _ "github.com/bytebase/bytebase/backend/plugin/advisor/tidb"
// Schema designer.
_ "github.com/bytebase/bytebase/backend/plugin/schema/mysql"
_ "github.com/bytebase/bytebase/backend/plugin/schema/oracle"
_ "github.com/bytebase/bytebase/backend/plugin/schema/pg"
_ "github.com/bytebase/bytebase/backend/plugin/schema/tidb"
+
+ // Transformers.
+ _ "github.com/bytebase/bytebase/backend/plugin/parser/sql/transform/mysql"
)
diff --git a/backend/server/ultimate_linux.go b/backend/server/ultimate_linux.go
index 4333b6fb72..051e4f692a 100644
--- a/backend/server/ultimate_linux.go
+++ b/backend/server/ultimate_linux.go
@@ -1,4 +1,4 @@
-//go:build !minimal
+//go:build !minidemo
package server
diff --git a/backend/sql-server/advise.go b/backend/sql-server/advise.go
deleted file mode 100644
index bcebefacb1..0000000000
--- a/backend/sql-server/advise.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package sqlserver
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "io"
- "net/http"
-
- metricapi "github.com/bytebase/bytebase/backend/metric"
-
- "github.com/labstack/echo/v4"
- "gopkg.in/yaml.v3"
-
- "github.com/bytebase/bytebase/backend/plugin/advisor"
- "github.com/bytebase/bytebase/backend/plugin/advisor/catalog"
- "github.com/bytebase/bytebase/backend/plugin/metric"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-var (
- _ catalog.Catalog = (*catalogService)(nil)
-)
-
-// catalogService is the catalog service for sql check api.
-type catalogService struct {
- finder *catalog.Finder
-}
-
-func newCatalogService(dbType storepb.Engine) *catalogService {
- return &catalogService{
- finder: catalog.NewEmptyFinder(&catalog.FinderContext{CheckIntegrity: false, EngineType: dbType, IgnoreCaseSensitive: false}),
- }
-}
-
-// GetFinder is the API message in catalog.
-func (c *catalogService) GetFinder() *catalog.Finder {
- return c.finder
-}
-
-type sqlCheckRequestBody struct {
- Statement string `json:"statement"`
- DatabaseType string `json:"databaseType"`
- TemplateID string `json:"templateId"`
- Override string `json:"override"`
-}
-
-func (s *Server) registerAdvisorRoutes(g *echo.Group) {
- g.POST("/advise", s.sqlCheckController)
-}
-
-// sqlCheckController godoc
-// @Summary Check the SQL statement.
-// @Description Parse and check the SQL statement according to the SQL review rules.
-// @Accept application/json
-// @Tags SQL review
-// @Produce json
-// @Param statement body string true "The SQL statement."
-// @Param databaseType body string true "The database type." Enums(MYSQL, POSTGRES, TIDB, OCEANBASE, SNOWFLAKE, MSSQL)
-// @Param templateId body string false "The SQL check template id. Required if the config is not specified." Enums(bb.sql-review.prod, bb.sql-review.dev)
-// @Param override body string false "The SQL check config override string in YAML format. Check https://github.com/bytebase/bytebase/tree/main/backend/plugin/advisor/config/sql-review.override.yaml for example. Required if the template is not specified."
-// @Success 200 {array} storepb.Advice
-// @Failure 400 {object} echo.HTTPError
-// @Failure 500 {object} echo.HTTPError
-// @Router /advise [post].
-func (s *Server) sqlCheckController(c echo.Context) error {
- request := &sqlCheckRequestBody{}
- body, err := io.ReadAll(c.Request().Body)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, "Failed to read request body").SetInternal(err)
- }
- if err := json.Unmarshal(body, request); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, "Cannot format request body").SetInternal(err)
- }
-
- if request.Statement == "" {
- return echo.NewHTTPError(http.StatusBadRequest, "Missing required SQL statement")
- }
-
- if request.Override == "" && request.TemplateID == "" {
- return echo.NewHTTPError(http.StatusBadRequest, "Missing required template or override")
- }
-
- engineTypeValue, ok := storepb.Engine_value[request.DatabaseType]
- if !ok {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Database %s is not support", request.DatabaseType))
- }
- engineType := storepb.Engine(engineTypeValue)
-
- ruleOverride := &advisor.SQLReviewConfigOverride{}
- if request.Override != "" {
- if err := yaml.Unmarshal([]byte(request.Override), ruleOverride); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid config: %v", request.Override)).SetInternal(err)
- }
- if request.TemplateID != "" && ruleOverride.Template != request.TemplateID {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("The config override should extend from the same template. Found %s in override but also get %s template in request.", ruleOverride.Template, request.TemplateID))
- }
- } else {
- ruleOverride.Template = request.TemplateID
- }
-
- ruleList, err := advisor.MergeSQLReviewRules(ruleOverride)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Cannot merge the config for template: %s, error: %v", ruleOverride.Template, err)).SetInternal(err)
- }
-
- adviceList, err := sqlCheck(
- engineType,
- "utf8mb4",
- "utf8mb4_general_ci",
- request.Statement,
- ruleList,
- newCatalogService(engineType),
- )
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to run sql check with error: %v", err)).SetInternal(err)
- }
-
- s.metricReporter.Report(&metric.Metric{
- Name: metricapi.SQLAdviseAPIMetricName,
- Value: 1,
- Labels: map[string]any{
- "database_type": engineType.String(),
- "platform": c.Request().Header.Get("X-Platform"),
- "repository": c.Request().Header.Get("X-Repository"),
- "actor": c.Request().Header.Get("X-Actor"),
- "source": c.Request().Header.Get("X-Source"),
- "version": c.Request().Header.Get("X-Version"),
- },
- })
-
- return c.JSON(http.StatusOK, adviceList)
-}
-
-func sqlCheck(
- dbType storepb.Engine,
- dbCharacterSet string,
- dbCollation string,
- statement string,
- ruleList []*storepb.SQLReviewRule,
- catalog catalog.Catalog,
-) ([]*storepb.Advice, error) {
- var adviceList []*storepb.Advice
-
- res, err := advisor.SQLReviewCheck(statement, ruleList, advisor.SQLReviewCheckContext{
- Charset: dbCharacterSet,
- Collation: dbCollation,
- DbType: dbType,
- Catalog: catalog,
- Driver: nil,
- Context: context.Background(),
- })
- if err != nil {
- return nil, err
- }
-
- adviceLevel := storepb.Advice_SUCCESS
- for _, advice := range res {
- switch advice.Status {
- case storepb.Advice_WARNING:
- if adviceLevel != storepb.Advice_ERROR {
- adviceLevel = storepb.Advice_WARNING
- }
- case storepb.Advice_ERROR:
- adviceLevel = storepb.Advice_ERROR
- case storepb.Advice_SUCCESS:
- continue
- }
-
- adviceList = append(adviceList, advice)
- }
-
- if len(adviceList) == 0 {
- adviceList = append(adviceList, &storepb.Advice{
- Status: storepb.Advice_SUCCESS,
- Code: advisor.Ok.Int32(),
- Title: "OK",
- Content: "",
- })
- }
- return adviceList, nil
-}
diff --git a/backend/sql-server/metric.go b/backend/sql-server/metric.go
deleted file mode 100644
index d532ea8d13..0000000000
--- a/backend/sql-server/metric.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package sqlserver
-
-import (
- "log/slog"
- "strconv"
- "time"
-
- "github.com/labstack/echo/v4"
-
- "github.com/bytebase/bytebase/backend/common/log"
- metricapi "github.com/bytebase/bytebase/backend/metric"
- "github.com/bytebase/bytebase/backend/plugin/metric"
-)
-
-type metricReporter struct {
- workspaceID string
- reporter metric.Reporter
-}
-
-func (m *metricReporter) Report(metric *metric.Metric) {
- if m.workspaceID == "" {
- return
- }
-
- if err := m.reporter.Report(m.workspaceID, metric); err != nil {
- slog.Error(
- "Failed to report metric",
- slog.String("metric", string(metricapi.OpenAPIMetricName)),
- log.BBError(err),
- )
- }
-}
-
-func metricMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) (err error) {
- start := time.Now()
-
- defer func() {
- duration := time.Since(start)
- requestMethod := c.Request().Method
- requestPath := c.Path()
- responseCode := c.Response().Status
-
- s.metricReporter.Report(&metric.Metric{
- Name: metricapi.OpenAPIMetricName,
- Value: 1,
- Labels: map[string]any{
- "latency_ns": strconv.FormatInt(duration.Nanoseconds(), 10),
- "request_method": requestMethod,
- "request_path": requestPath,
- "response_code": strconv.Itoa(responseCode),
- },
- })
- }()
-
- if err := next(c); err != nil {
- c.Error(err)
- }
- return nil
- }
-}
diff --git a/backend/sql-server/profile.go b/backend/sql-server/profile.go
deleted file mode 100644
index 0e13a08438..0000000000
--- a/backend/sql-server/profile.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package sqlserver
-
-import "github.com/bytebase/bytebase/backend/common"
-
-// Profile is the configuration to start main server.
-type Profile struct {
- // Mode can be "prod" or "dev"
- Mode common.ReleaseMode
- // BackendHost is the listening backend host for server
- BackendHost string
- // BackendPort is the binding backend port for server.
- BackendPort int
- // Debug decides the log level
- Debug bool
- // Version is the bytebase's version
- Version string
- // Git commit hash of the build
- GitCommit string
- // MetricConnectionKey is the connection key for metric.
- MetricConnectionKey string
- // WorkspaceID is the identifier for SQL Service, used by metric.
- WorkspaceID string
-}
diff --git a/backend/sql-server/server.go b/backend/sql-server/server.go
deleted file mode 100644
index 15938b20f2..0000000000
--- a/backend/sql-server/server.go
+++ /dev/null
@@ -1,115 +0,0 @@
-// Package sqlserver is the binary for SQL review server.
-package sqlserver
-
-import (
- "context"
- "fmt"
- "log/slog"
- "net/http"
- "time"
-
- "github.com/bytebase/bytebase/backend/plugin/metric/segment"
-
- "github.com/labstack/echo-contrib/pprof"
- "github.com/labstack/echo-contrib/prometheus"
- "github.com/labstack/echo/v4"
- "github.com/labstack/echo/v4/middleware"
-
- "github.com/bytebase/bytebase/backend/common"
-)
-
-// Server is the Bytebase server.
-type Server struct {
- profile Profile
- e *echo.Echo
- startedTs int64
- metricReporter *metricReporter
-}
-
-// NewServer creates a server.
-func NewServer(ctx context.Context, prof Profile) (*Server, error) {
- s := &Server{
- profile: prof,
- startedTs: time.Now().Unix(),
- metricReporter: &metricReporter{
- workspaceID: prof.WorkspaceID,
- reporter: segment.NewReporter(prof.MetricConnectionKey),
- },
- }
-
- // Display config
- slog.Info("-----Config BEGIN-----")
- slog.Info(fmt.Sprintf("mode=%s", prof.Mode))
- slog.Info(fmt.Sprintf("server=%s:%d", prof.BackendHost, prof.BackendPort))
- slog.Info(fmt.Sprintf("debug=%t", prof.Debug))
- slog.Info(fmt.Sprintf("workspaceID=%s", prof.WorkspaceID))
- slog.Info("-----Config END-------")
-
- serverStarted := false
- defer func() {
- if !serverStarted {
- _ = s.Shutdown(ctx)
- }
- }()
-
- e := echo.New()
- e.Debug = prof.Debug
- s.e = e
-
- // Middleware
- if prof.Mode == common.ReleaseModeDev || prof.Debug {
- e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
- Skipper: func(c echo.Context) bool {
- return !common.HasPrefixes(c.Path(), "/v1")
- },
- Format: `{"time":"${time_rfc3339}",` +
- `"method":"${method}","uri":"${uri}",` +
- `"status":${status},"error":"${error}"}` + "\n",
- }))
- }
- e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{}))
-
- apiGroup := e.Group("/v1")
- apiGroup.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
- return metricMiddleware(s, next)
- })
- s.registerAdvisorRoutes(apiGroup)
-
- // Register healthz endpoint.
- e.GET("/healthz", func(c echo.Context) error {
- return c.String(http.StatusOK, "OK!\n")
- })
- // Register pprof endpoints.
- pprof.Register(e)
- // Register prometheus metrics endpoint.
- p := prometheus.NewPrometheus("api", nil)
- p.Use(e)
-
- serverStarted = true
- return s, nil
-}
-
-// Run will run the server.
-func (s *Server) Run() error {
- return s.e.Start(fmt.Sprintf(":%d", s.profile.BackendPort))
-}
-
-// Shutdown will shut down the server.
-func (s *Server) Shutdown(ctx context.Context) error {
- slog.Info("Trying to stop Bytebase SQL Service ....")
- slog.Info("Trying to gracefully shutdown server")
-
- ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
- defer cancel()
-
- // Shutdown echo
- if s.e != nil {
- if err := s.e.Shutdown(ctx); err != nil {
- s.e.Logger.Fatal(err)
- }
- }
-
- slog.Info("Bytebase SQL Service stopped properly")
-
- return nil
-}
diff --git a/scripts/.air.toml b/scripts/.air.toml
index 404320a64e..9e35cd9a72 100644
--- a/scripts/.air.toml
+++ b/scripts/.air.toml
@@ -11,8 +11,8 @@ cmd = """
CGO_ENABLED=1 \
go build \
-p=8 \
- -ldflags="-debugtextsize=1073741824 -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=$(git rev-parse HEAD)'" \
- --tags "minimal" \
+ -ldflags="-X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=$(git rev-parse HEAD)'" \
+ --tags "" \
-o ./.air/bytebase ./backend/bin/server/main.go"""
delay = 500
exclude_dir = [
diff --git a/scripts/Dockerfile.render-demo b/scripts/Dockerfile.render-demo
index f781c44b34..f07dec2ba9 100644
--- a/scripts/Dockerfile.render-demo
+++ b/scripts/Dockerfile.render-demo
@@ -44,7 +44,7 @@ COPY ./scripts/VERSION .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
# go-sqlite3 requires CGO_ENABLED
RUN VERSION=`cat ./VERSION` && CGO_ENABLED=1 go build \
- --tags "${RELEASE},embed_frontend,minimal,minidemo,docker" \
+ --tags "${RELEASE},embed_frontend,minidemo,docker" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=${RENDER_GIT_COMMIT}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.builduser=${BUILD_USER}'" \
-o bytebase \
./backend/bin/server/main.go