Skip to content

Commit

Permalink
controllers: support migrate down command (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored May 5, 2024
1 parent be134d6 commit 5bbc936
Show file tree
Hide file tree
Showing 11 changed files with 654 additions and 128 deletions.
19 changes: 18 additions & 1 deletion api/v1alpha1/atlasmigration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ type (
Conditions []metav1.Condition `json:"conditions,omitempty"`
// LastAppliedVersion is the version of the most recent successful versioned migration.
LastAppliedVersion string `json:"lastAppliedVersion,omitempty"`
//LastDeploymentURL is the Deployment URL of the most recent successful versioned migration.
// LastDeploymentURL is the Deployment URL of the most recent successful versioned migration.
LastDeploymentURL string `json:"lastDeploymentUrl,omitempty"`
// ApprovalURL is the URL to approve the migration.
ApprovalURL string `json:"approvalUrl,omitempty"`
// ObservedHash is the hash of the most recent successful versioned migration.
ObservedHash string `json:"observed_hash"`
// LastApplied is the unix timestamp of the most recent successful versioned migration.
Expand Down Expand Up @@ -80,6 +82,8 @@ type (
// ExecOrder controls how Atlas computes and executes pending migration files to the database.
// +kubebuilder:default=linear
ExecOrder MigrateExecOrder `json:"execOrder,omitempty"`
// ProtectedFlows defines the protected flows of a deployment.
ProtectedFlows *ProtectFlows `json:"protectedFlows,omitempty"`
}
// Cloud defines the Atlas Cloud configuration.
Cloud struct {
Expand All @@ -106,6 +110,19 @@ type (
Name string `json:"name,omitempty"`
Tag string `json:"tag,omitempty"`
}
// ProtectedFlows defines the protected flows of a deployment.
ProtectFlows struct {
MigrateDown *DeploymentFlow `json:"migrateDown,omitempty"`
}
// DeploymentFlow defines the flow of a deployment.
DeploymentFlow struct {
// Allow allows the flow to be executed.
// +kubebuilder:default=false
Allow bool `json:"allow,omitempty"`
// AutoApprove allows the flow to be automatically approved.
// +kubebuilder:default=false
AutoApprove bool `json:"autoApprove,omitempty"`
}
)

// ExecOrder controls how Atlas computes and executes pending migration files to the database.
Expand Down
40 changes: 40 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions charts/atlas-operator/templates/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,23 @@ spec:
- linear-skip
- non-linear
type: string
protectedFlows:
description: ProtectedFlows defines the protected flows of a deployment.
properties:
migrateDown:
description: DeploymentFlow defines the flow of a deployment.
properties:
allow:
default: false
description: Allow allows the flow to be executed.
type: boolean
autoApprove:
default: false
description: AutoApprove allows the flow to be automatically
approved.
type: boolean
type: object
type: object
revisionsSchema:
description: RevisionsSchema defines the schema that revisions table
resides in
Expand Down Expand Up @@ -297,6 +314,9 @@ spec:
status:
description: AtlasMigrationStatus defines the observed state of AtlasMigration
properties:
approvalUrl:
description: ApprovalURL is the URL to approve the migration.
type: string
conditions:
description: Conditions represent the latest available observations
of an object's state.
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/db.atlasgo.io_atlasmigrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ spec:
- linear-skip
- non-linear
type: string
protectedFlows:
description: ProtectedFlows defines the protected flows of a deployment.
properties:
migrateDown:
description: DeploymentFlow defines the flow of a deployment.
properties:
allow:
default: false
description: Allow allows the flow to be executed.
type: boolean
autoApprove:
default: false
description: AutoApprove allows the flow to be automatically
approved.
type: boolean
type: object
type: object
revisionsSchema:
description: RevisionsSchema defines the schema that revisions table
resides in
Expand Down Expand Up @@ -312,6 +329,9 @@ spec:
status:
description: AtlasMigrationStatus defines the observed state of AtlasMigration
properties:
approvalUrl:
description: ApprovalURL is the URL to approve the migration.
type: string
conditions:
description: Conditions represent the latest available observations
of an object's state.
Expand Down
21 changes: 21 additions & 0 deletions config/integration/migration/mysql_migrate_down.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: db.atlasgo.io/v1alpha1
kind: AtlasMigration
spec:
protectedFlows:
migrateDown:
allow: true
autoApprove: true
Loading

0 comments on commit 5bbc936

Please sign in to comment.