Skip to content

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

chore: move migrationType to migrationDetail (#2945)

Danny Xu3b19a0f4b5d4
diff --git a/api/issue.go b/api/issue.go
index 95c4226906..e07ecf6f7c 100644
--- a/api/issue.go
+++ b/api/issue.go
@@ -146,6 +146,9 @@ type CreateDatabaseContext struct {
// MigrationDetail is the detail for database migration such as Migrate, Data.
type MigrationDetail struct {
+ // MigrationType is the type of a migration.
+ // MigrationType can be empty for gh-ost type of migration.
+ MigrationType db.MigrationType `json:"migrationType"`
// DatabaseID is the ID of a database.
DatabaseID int `json:"databaseId"`
// DatabaseName is the name of databases, mutually exclusive to DatabaseID.
@@ -162,8 +165,6 @@ type MigrationDetail struct {
// MigrationContext is the issue create context for database migration such as Migrate, Data.
type MigrationContext struct {
- // MigrationType is the type of a migration.
- MigrationType db.MigrationType `json:"migrationType"`
// DetailList is the details of schema update.
// When a project is in tenant mode, there should be one item in the list.
DetailList []*MigrationDetail `json:"detailList"`
diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.ts
index a2d3cb8394..169346db15 100644
--- a/frontend/src/components/Issue/logic/common.ts
+++ b/frontend/src/components/Issue/logic/common.ts
@@ -182,19 +182,19 @@ export const useCommonLogic = () => {
// for standard issue pipeline (1 * 1 or M * 1)
// copy user edited tasks back to issue.createContext
const taskList = flattenTaskList<TaskCreate>(issueCreate);
+ const migrationType = taskList[0].migrationType!;
const detailList: MigrationDetail[] = taskList.map((task) => {
const db = databaseStore.getDatabaseById(task.databaseId!);
return {
+ migrationType: migrationType,
databaseId: task.databaseId!,
databaseName: "", // Only `databaseId` is needed in standard pipeline.
statement: maybeFormatStatementOnSave(task.statement, db),
earliestAllowedTs: task.earliestAllowedTs,
};
});
- const migrationType = taskList[0].migrationType!;
issueCreate.createContext = {
- migrationType,
detailList: detailList,
};
diff --git a/frontend/src/components/SyncDatabaseSchemaPrepForm.vue b/frontend/src/components/SyncDatabaseSchemaPrepForm.vue
index bc6f27b495..090ad1b153 100644
--- a/frontend/src/components/SyncDatabaseSchemaPrepForm.vue
+++ b/frontend/src/components/SyncDatabaseSchemaPrepForm.vue
@@ -403,9 +403,9 @@ const handleConfirmButtonClick = async () => {
state.targetSchemaInfo.databaseId as DatabaseId
);
const migrationContext: MigrationContext = {
- migrationType: "MIGRATE",
detailList: [
{
+ migrationType: "MIGRATE",
databaseId: targetDatabase.id,
databaseName: targetDatabase.name,
statement: state.editStatement,
diff --git a/frontend/src/plugins/issue/logic/initialize/standard.ts b/frontend/src/plugins/issue/logic/initialize/standard.ts
index 5eac2acf7f..cbd0c5ef57 100644
--- a/frontend/src/plugins/issue/logic/initialize/standard.ts
+++ b/frontend/src/plugins/issue/logic/initialize/standard.ts
@@ -36,9 +36,9 @@ export const buildNewStandardIssue = async (
migrationType === "BASELINE" ? ESTABLISH_BASELINE_SQL : VALIDATE_ONLY_SQL;
const createContext: IssueCreateContext = {
- migrationType,
detailList: databaseList.map((db) => {
return {
+ migrationType: migrationType,
databaseId: db.id,
databaseName: "", // Only `databaseId` is needed in standard pipeline.
statement,
diff --git a/frontend/src/plugins/issue/logic/initialize/tenant.ts b/frontend/src/plugins/issue/logic/initialize/tenant.ts
index 30d555b211..cb6944f75f 100644
--- a/frontend/src/plugins/issue/logic/initialize/tenant.ts
+++ b/frontend/src/plugins/issue/logic/initialize/tenant.ts
@@ -48,9 +48,9 @@ const buildNewTenantSchemaUpdateIssue = async (
migrationType = "DATA";
}
helper.issueCreate!.createContext = {
- migrationType,
detailList: [
{
+ migrationType: migrationType,
databaseName: route.query.databaseName,
statement: VALIDATE_ONLY_SQL,
},
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index f0f742d51f..9c56bd6d32 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -45,6 +45,7 @@ export type CreateDatabaseContext = {
};
export type MigrationDetail = {
+ migrationType: MigrationType;
databaseId: DatabaseId;
databaseName: string;
statement: string;
@@ -57,7 +58,6 @@ export type UpdateSchemaGhostDetail = MigrationDetail & {
};
export type MigrationContext = {
- migrationType: MigrationType;
detailList: MigrationDetail[];
vcsPushEvent?: VCSPushEvent;
};
diff --git a/scripts/.air.toml b/scripts/.air.toml
index bcb1c04733..793382816e 100644
--- a/scripts/.air.toml
+++ b/scripts/.air.toml
@@ -2,7 +2,7 @@ root = "."
tmp_dir = ".air"
[build]
- full_bin = 'BB_REDIRECT_URL=http:\/\/localhost:3000 ./.air/bytebase --port 8080 --external-url http:\/\/localhost:3000 --data . --debug'
+ full_bin = 'BB_REDIRECT_URL=http:\/\/localhost:3000 ./.air/bytebase --port 8080 --external-url http:\/\/1e29-115-194-90-33.jp.ngrok.io --data . --debug'
## Use --tags "store.db" to enable SQL query logging against our metadata db.
cmd = """
go build \
diff --git a/server/issue.go b/server/issue.go
index 97756d9efd..64d3593291 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -613,17 +613,10 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
}
}
}
- create := &api.PipelineCreate{}
- switch c.MigrationType {
- case db.Baseline:
- create.Name = "Establish database baseline pipeline"
- case db.Migrate:
- create.Name = "Update database schema pipeline"
- case db.Data:
- create.Name = "Update database data pipeline"
- default:
- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid migration type %q", c.MigrationType))
+ create := &api.PipelineCreate{
+ Name: "Change database pipeline",
}
+
project, err := s.store.GetProjectByID(ctx, issueCreate.ProjectID)
if err != nil {
return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project with ID %d", issueCreate.ProjectID)).SetInternal(err)
@@ -632,9 +625,11 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
// If migration type is establishing baseline and project's workflow is VCS,
// then the context must contain a VCS push event field. We need this VCS
// context to identify the write-back destination after migration.
- if c.MigrationType == db.Baseline && project.WorkflowType == api.VCSWorkflow {
- if c.VCSPushEvent == nil {
- return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create establishing baseline issue for GitOps workflow project, vcs context missing")
+ for _, detail := range c.DetailList {
+ if detail.MigrationType == db.Baseline && project.WorkflowType == api.VCSWorkflow {
+ if c.VCSPushEvent == nil {
+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create establishing baseline issue for GitOps workflow project, vcs context missing")
+ }
}
}
@@ -644,8 +639,10 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
if !s.feature(api.FeatureMultiTenancy) {
return nil, echo.NewHTTPError(http.StatusForbidden, api.FeatureMultiTenancy.AccessErrorMessage())
}
- if c.MigrationType != db.Migrate && c.MigrationType != db.Data {
- return nil, echo.NewHTTPError(http.StatusBadRequest, "Only Migrate and Data type migration can be performed on tenant mode project")
+ for _, detail := range c.DetailList {
+ if detail.MigrationType != db.Migrate && detail.MigrationType != db.Data {
+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Only Migrate and Data type migration can be performed on tenant mode project")
+ }
}
if len(c.DetailList) != 1 {
return nil, echo.NewHTTPError(http.StatusBadRequest, "Tenant mode project should have exactly one update schema detail")
@@ -668,7 +665,7 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
return nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", d.DatabaseID))
}
- taskCreate, err := getUpdateTask(database, c.MigrationType, c.VCSPushEvent, d, schemaVersion)
+ taskCreate, err := getUpdateTask(database, c.VCSPushEvent, d, schemaVersion)
if err != nil {
return nil, err
}
@@ -701,7 +698,7 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
environmentSet[database.Instance.Environment.Name] = true
environmentID = database.Instance.EnvironmentID
- taskCreate, err := getUpdateTask(database, c.MigrationType, c.VCSPushEvent, d, schemaVersion)
+ taskCreate, err := getUpdateTask(database, c.VCSPushEvent, d, schemaVersion)
if err != nil {
return nil, err
}
@@ -736,7 +733,7 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
}
envToDatabaseMap := make(map[envKey][]api.TaskCreate)
for _, d := range c.DetailList {
- if c.MigrationType == db.Migrate && d.Statement == "" {
+ if d.MigrationType == db.Migrate && d.Statement == "" {
return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, sql statement missing")
}
database, err := s.store.GetDatabase(ctx, &api.DatabaseFind{ID: &d.DatabaseID})
@@ -751,7 +748,7 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
if d.SchemaVersion != "" {
schemaVersion = d.SchemaVersion
}
- taskCreate, err := getUpdateTask(database, c.MigrationType, c.VCSPushEvent, d, schemaVersion)
+ taskCreate, err := getUpdateTask(database, c.VCSPushEvent, d, schemaVersion)
if err != nil {
return nil, err
}
@@ -833,16 +830,16 @@ func (s *Server) getPipelineCreateForDatabaseSchemaUpdateGhost(ctx context.Conte
return create, nil
}
-func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPushEvent *vcs.PushEvent, d *api.MigrationDetail, schemaVersion string) (*api.TaskCreate, error) {
+func getUpdateTask(database *api.Database, vcsPushEvent *vcs.PushEvent, d *api.MigrationDetail, schemaVersion string) (*api.TaskCreate, error) {
taskName := fmt.Sprintf("Establish %q baseline", database.Name)
- switch migrationType {
+ switch d.MigrationType {
case db.Migrate:
taskName = fmt.Sprintf("DDL(schema) for %q", database.Name)
case db.Data:
taskName = fmt.Sprintf("DML(data) for %q", database.Name)
}
payload := api.TaskDatabaseSchemaUpdatePayload{}
- payload.MigrationType = migrationType
+ payload.MigrationType = d.MigrationType
payload.Statement = d.Statement
payload.SchemaVersion = schemaVersion
if vcsPushEvent != nil {
@@ -851,14 +848,14 @@ func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPu
bytes, err := json.Marshal(payload)
if err != nil {
errMsg := fmt.Sprintf("Failed to marshal database schema update payload: %v", err)
- if migrationType == db.Data {
+ if d.MigrationType == db.Data {
errMsg = fmt.Sprintf("Failed to marshal database data update payload: %v", err)
}
return nil, echo.NewHTTPError(http.StatusInternalServerError, errMsg)
}
taskType := api.TaskDatabaseSchemaUpdate
- if migrationType == db.Data {
+ if d.MigrationType == db.Data {
taskType = api.TaskDatabaseDataUpdate
}
return &api.TaskCreate{
@@ -869,7 +866,7 @@ func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPu
Type: taskType,
Statement: d.Statement,
EarliestAllowedTs: d.EarliestAllowedTs,
- MigrationType: migrationType,
+ MigrationType: d.MigrationType,
Payload: string(bytes),
}, nil
}
diff --git a/server/webhook.go b/server/webhook.go
index af64329095..1b878b94f8 100644
--- a/server/webhook.go
+++ b/server/webhook.go
@@ -384,21 +384,17 @@ func (s *Server) processFilesInProject(ctx context.Context, pushEvent vcs.PushEv
var migrationDetailList []*api.MigrationDetail
var activityCreateList []*api.ActivityCreate
var createdIssueList []string
- // Default to DATA migration. If later we found any MIGRATE migration file, we set migrationType to MIGRATE.
- // The reason for this design is that, if a user merges DDL/DML in a single PR/MR, we suppose the user is possibly changing the schema while inserting/updating some seed/existing data.
- // If the user wants to create a pure DML issue, they should create a dedicated PR/MR only containing DML SQL statements.
- migrationTypeDDL := db.Data
for _, fileInfo := range fileInfoList {
if fileInfo.fType == schemaFileType {
if repo.Project.SchemaChangeType == api.ProjectSchemaChangeTypeSDL {
// Create one issue per schema file for SDL project.
- migrationDetailListForFile, activityCreateListForFile := s.prepareIssueFromPushEventSDL(ctx, repo, pushEvent, fileInfo.migrationInfo, fileInfo.item.FileName)
+ migrationDetailListForFile, activityCreateListForFile := s.prepareIssueFromSDLFile(ctx, repo, pushEvent, fileInfo.migrationInfo, fileInfo.item.FileName)
activityCreateList = append(activityCreateList, activityCreateListForFile...)
if len(migrationDetailListForFile) != 0 {
issueName := fmt.Sprintf("Apply schema diff by file %s", strings.TrimPrefix(fileInfo.item.FileName, repo.BaseDirectory+"/"))
creatorID := s.getIssueCreatorID(ctx, pushEvent.FileCommit.AuthorEmail)
- if err := s.createIssueFromMigrationDetailList(ctx, issueName, pushEvent, creatorID, repo.ProjectID, fileInfo.migrationInfo.Type, migrationDetailListForFile); err != nil {
+ if err := s.createIssueFromMigrationDetailList(ctx, issueName, pushEvent, creatorID, repo.ProjectID, migrationDetailListForFile); err != nil {
return "", false, activityCreateList, echo.NewHTTPError(http.StatusInternalServerError, "Failed to create issue").SetInternal(err)
}
createdIssueList = append(createdIssueList, issueName)
@@ -413,10 +409,7 @@ func (s *Server) processFilesInProject(ctx context.Context, pushEvent vcs.PushEv
// 1) DML is always migration-based.
// 2) We may have a limitation in SDL implementation.
// 3) User just wants to break the glass.
- if fileInfo.migrationInfo.Type == db.Migrate {
- migrationTypeDDL = db.Migrate
- }
- migrationDetailListForFile, activityCreateListForFile := s.prepareIssueFromPushEventDDL(ctx, repo, pushEvent, fileInfo.item.FileName, fileInfo.item.ItemType, fileInfo.migrationInfo)
+ migrationDetailListForFile, activityCreateListForFile := s.prepareIssueFromFile(ctx, repo, pushEvent, fileInfo.item.FileName, fileInfo.item.ItemType, fileInfo.migrationInfo)
activityCreateList = append(activityCreateList, activityCreateListForFile...)
migrationDetailList = append(migrationDetailList, migrationDetailListForFile...)
}
@@ -429,7 +422,7 @@ func (s *Server) processFilesInProject(ctx context.Context, pushEvent vcs.PushEv
// Create one issue per push event for DDL project, or non-schema files for SDL project.
issueName := pushEvent.CommitList[0].Title
creatorID := s.getIssueCreatorID(ctx, pushEvent.FileCommit.AuthorEmail)
- if err := s.createIssueFromMigrationDetailList(ctx, issueName, pushEvent, creatorID, repo.ProjectID, migrationTypeDDL, migrationDetailList); err != nil {
+ if err := s.createIssueFromMigrationDetailList(ctx, issueName, pushEvent, creatorID, repo.ProjectID, migrationDetailList); err != nil {
return "", len(createdIssueList) != 0, activityCreateList, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to create issue %s", issueName)).SetInternal(err)
}
@@ -447,21 +440,23 @@ func sortFilesBySchemaVersion(fileInfoList []fileInfo) []fileInfo {
return ret
}
-func (s *Server) createIssueFromMigrationDetailList(ctx context.Context, issueName string, pushEvent vcs.PushEvent, creatorID, projectID int, migrationType db.MigrationType, migrationDetailList []*api.MigrationDetail) error {
+func (s *Server) createIssueFromMigrationDetailList(ctx context.Context, issueName string, pushEvent vcs.PushEvent, creatorID, projectID int, migrationDetailList []*api.MigrationDetail) error {
createContext, err := json.Marshal(
&api.MigrationContext{
- MigrationType: migrationType,
- VCSPushEvent: &pushEvent,
- DetailList: migrationDetailList,
+ VCSPushEvent: &pushEvent,
+ DetailList: migrationDetailList,
},
)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal update schema context").SetInternal(err)
}
- issueType := api.IssueDatabaseSchemaUpdate
- if migrationType == db.Data {
- issueType = api.IssueDatabaseDataUpdate
+ // TODO(d): unify issue type for database changes.
+ issueType := api.IssueDatabaseDataUpdate
+ for _, detail := range migrationDetailList {
+ if detail.MigrationType == db.Migrate || detail.MigrationType == db.Baseline {
+ issueType = api.IssueDatabaseSchemaUpdate
+ }
}
issueCreate := &api.IssueCreate{
ProjectID: projectID,
@@ -644,9 +639,9 @@ func (s *Server) readFileContent(ctx context.Context, pushEvent vcs.PushEvent, r
return content, nil
}
-// prepareIssueFromPushEventSDL returns the migration info and a list of update
+// prepareIssueFromSDLFile returns the migration info and a list of update
// schema details derived from the given push event for SDL.
-func (s *Server) prepareIssueFromPushEventSDL(ctx context.Context, repo *api.Repository, pushEvent vcs.PushEvent, schemaInfo *db.MigrationInfo, file string) ([]*api.MigrationDetail, []*api.ActivityCreate) {
+func (s *Server) prepareIssueFromSDLFile(ctx context.Context, repo *api.Repository, pushEvent vcs.PushEvent, schemaInfo *db.MigrationInfo, file string) ([]*api.MigrationDetail, []*api.ActivityCreate) {
dbName := schemaInfo.Database
if dbName == "" {
log.Debug("Ignored schema file without a database name", zap.String("file", file))
@@ -665,8 +660,10 @@ func (s *Server) prepareIssueFromPushEventSDL(ctx context.Context, repo *api.Rep
if repo.Project.TenantMode == api.TenantModeTenant {
migrationDetailList = append(migrationDetailList,
&api.MigrationDetail{
- DatabaseName: dbName,
- Statement: statement,
+ // TODO(d): make it to SDL migration.
+ MigrationType: db.Migrate,
+ DatabaseName: dbName,
+ Statement: statement,
},
)
return migrationDetailList, nil
@@ -688,8 +685,10 @@ func (s *Server) prepareIssueFromPushEventSDL(ctx context.Context, repo *api.Rep
migrationDetailList = append(migrationDetailList,
&api.MigrationDetail{
- DatabaseID: database.ID,
- Statement: diff,
+ // TODO(d): make it to SDL migration.
+ MigrationType: db.Migrate,
+ DatabaseID: database.ID,
+ Statement: diff,
},
)
}
@@ -697,9 +696,9 @@ func (s *Server) prepareIssueFromPushEventSDL(ctx context.Context, repo *api.Rep
return migrationDetailList, activityCreateList
}
-// prepareIssueFromPushEventDDL returns a list of update schema details derived
+// prepareIssueFromFile returns a list of update schema details derived
// from the given push event for DDL.
-func (s *Server) prepareIssueFromPushEventDDL(ctx context.Context, repo *api.Repository, pushEvent vcs.PushEvent, fileName string, fileType vcs.FileItemType, migrationInfo *db.MigrationInfo) ([]*api.MigrationDetail, []*api.ActivityCreate) {
+func (s *Server) prepareIssueFromFile(ctx context.Context, repo *api.Repository, pushEvent vcs.PushEvent, fileName string, fileType vcs.FileItemType, migrationInfo *db.MigrationInfo) ([]*api.MigrationDetail, []*api.ActivityCreate) {
statement, err := s.readFileContent(ctx, pushEvent, repo, fileName)
if err != nil {
activityCreate := getIgnoredFileActivityCreate(repo.ProjectID, pushEvent, fileName, errors.Wrap(err, "Failed to read file content"))
@@ -709,9 +708,14 @@ func (s *Server) prepareIssueFromPushEventDDL(ctx context.Context, repo *api.Rep
var migrationDetailList []*api.MigrationDetail
// TODO(dragonly): handle modified file for tenant mode.
+ migrationType := db.Migrate
+ if migrationInfo.Type == db.Data {
+ migrationType = db.Data
+ }
if repo.Project.TenantMode == api.TenantModeTenant {
migrationDetailList = append(migrationDetailList,
&api.MigrationDetail{
+ MigrationType: migrationType,
DatabaseName: migrationInfo.Database,
Statement: statement,
SchemaVersion: migrationInfo.Version,
@@ -730,6 +734,7 @@ func (s *Server) prepareIssueFromPushEventDDL(ctx context.Context, repo *api.Rep
for _, database := range databases {
migrationDetailList = append(migrationDetailList,
&api.MigrationDetail{
+ MigrationType: migrationType,
DatabaseID: database.ID,
Statement: statement,
SchemaVersion: migrationInfo.Version,
diff --git a/tests/ghost_test.go b/tests/ghost_test.go
index 8b9977ee51..4038377a6d 100644
--- a/tests/ghost_test.go
+++ b/tests/ghost_test.go
@@ -144,7 +144,6 @@ func TestGhostSchemaUpdate(t *testing.T) {
a.Equal(instance.ID, database.Instance.ID)
createContext, err := json.Marshal(&api.MigrationContext{
- MigrationType: db.Migrate,
DetailList: []*api.MigrationDetail{
{
DatabaseID: database.ID,
diff --git a/tests/schema_update_test.go b/tests/schema_update_test.go
index 33d3709135..99fd256d09 100644
--- a/tests/schema_update_test.go
+++ b/tests/schema_update_test.go
@@ -93,11 +93,11 @@ func TestSchemaAndDataUpdate(t *testing.T) {
// Create an issue that updates database schema.
createContext, err := json.Marshal(&api.MigrationContext{
- MigrationType: db.Migrate,
DetailList: []*api.MigrationDetail{
{
- DatabaseID: database.ID,
- Statement: migrationStatement,
+ MigrationType: db.Migrate,
+ DatabaseID: database.ID,
+ Statement: migrationStatement,
},
},
})
@@ -123,11 +123,11 @@ func TestSchemaAndDataUpdate(t *testing.T) {
// Create an issue that updates database data.
createContext, err = json.Marshal(&api.MigrationContext{
- MigrationType: db.Data,
DetailList: []*api.MigrationDetail{
{
- DatabaseID: database.ID,
- Statement: dataUpdateStatement,
+ MigrationType: db.Data,
+ DatabaseID: database.ID,
+ Statement: dataUpdateStatement,
},
},
})
diff --git a/tests/sql_review_test.go b/tests/sql_review_test.go
index c0687a5f3b..c9af3c5d1f 100644
--- a/tests/sql_review_test.go
+++ b/tests/sql_review_test.go
@@ -764,11 +764,11 @@ func TestSQLReviewForMySQL(t *testing.T) {
func createIssueAndReturnSQLReviewResult(a *require.Assertions, ctl *controller, databaseID int, projectID int, assigneeID int, statement string, wait bool) []api.TaskCheckResult {
createContext, err := json.Marshal(&api.MigrationContext{
- MigrationType: db.Migrate,
DetailList: []*api.MigrationDetail{
{
- DatabaseID: databaseID,
- Statement: statement,
+ MigrationType: db.Migrate,
+ DatabaseID: databaseID,
+ Statement: statement,
},
},
})
diff --git a/tests/tenant_test.go b/tests/tenant_test.go
index 7dafb0a4f7..1b0b1ecf2d 100644
--- a/tests/tenant_test.go
+++ b/tests/tenant_test.go
@@ -152,11 +152,11 @@ func TestTenant(t *testing.T) {
// Create an issue that updates database schema.
createContext, err := json.Marshal(&api.MigrationContext{
- MigrationType: db.Migrate,
DetailList: []*api.MigrationDetail{
{
- DatabaseName: databaseName,
- Statement: migrationStatement,
+ MigrationType: db.Migrate,
+ DatabaseName: databaseName,
+ Statement: migrationStatement,
},
},
})
@@ -617,11 +617,11 @@ func TestTenantDatabaseNameTemplate(t *testing.T) {
// Create an issue that updates database schema.
createContext, err := json.Marshal(&api.MigrationContext{
- MigrationType: db.Migrate,
DetailList: []*api.MigrationDetail{
{
- DatabaseName: baseDatabaseName,
- Statement: migrationStatement,
+ MigrationType: db.Migrate,
+ DatabaseName: baseDatabaseName,
+ Statement: migrationStatement,
},
},
})