Skip to content

Commit

Permalink
atlasaction/comments: update edit this plan comment (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Oct 18, 2024
1 parent a6dae11 commit a747e59
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
31 changes: 22 additions & 9 deletions atlasaction/comments/schema-plan.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@
{{- template "schema-lint" . -}}
<hr>
<details>
<summary>πŸ“ To edit this plan, follow these steps</summary>
<ol>
<li>Run <code>atlas schema plan pull --url "{{ .Plan.File.URL }}" > {{ .Plan.File.Name }}.plan.hcl</code></li>
<li>Modify the plan.</li>
<li>Push the plan using <code>atlas schema plan push --pending --env {{ .EnvName }} --file {{ .Plan.File.Name }}.plan.hcl</code></li>
{{- if .RerunCommand -}}
<li>Re-trigger this action using <code>{{ .RerunCommand }}</code></li>
{{- end -}}
</ol>
<summary>πŸ“ Steps to edit this migration plan</summary>

1\. Run the following command to pull the generated plan to your local workstation:
```bash
atlas schema plan pull --url "{{ .Plan.File.URL }}" > {{ .Plan.File.Name }}.plan.hcl
```

2\. Open `{{ .Plan.File.Name }}` in your editor and modify it as needed. Note that the result of the plan should align
the database with the desired state. Otherwise, Atlas will report a schema drift.

3\. Push the updated plan to the registry using the following command:
```bash
atlas schema plan push --pending --env {{ .EnvName }} --file {{ .Plan.File.Name }}.plan.hcl
```

{{- if .RerunCommand }}
4\. Re-trigger the `schema/plan` action to update this comment:
```bash
{{ .RerunCommand }}
```
{{- end }}

</details>
{{- define "schema-lint" -}}
<table>
Expand Down
20 changes: 15 additions & 5 deletions atlasaction/testdata/gitlab/schema-plan.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,19 @@ CREATE TABLE `1` (
<td></td>
</tr></tbody></table><hr>
<details>
<summary>πŸ“ To edit this plan, follow these steps</summary>
<ol>
<li>Run <code>atlas schema plan pull --url "atlas://app/plans/20241010143904" > 20241010143904.plan.hcl</code></li>
<li>Modify the plan.</li>
<li>Push the plan using <code>atlas schema plan push --pending --env --file 20241010143904.plan.hcl</code></li></ol>
<summary>πŸ“ Steps to edit this migration plan</summary>

1\. Run the following command to pull the generated plan to your local workstation:
```bash
atlas schema plan pull --url "atlas://app/plans/20241010143904" > 20241010143904.plan.hcl
```

2\. Open `20241010143904` in your editor and modify it as needed. Note that the result of the plan should align
the database with the desired state. Otherwise, Atlas will report a schema drift.

3\. Push the updated plan to the registry using the following command:
```bash
atlas schema plan push --pending --env --file 20241010143904.plan.hcl
```

</details>

0 comments on commit a747e59

Please sign in to comment.