Skip to content

chore: add script to analyze which releases have migrations #10823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 27, 2023

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Nov 21, 2023

What is this?

This is a little script that can help find which release upgrades have database migrations and which migrations they have. I created this to investigate how difficult downgrading coder would be. I believe this has value outside of that though too. I have manually dug into migrations trying to find what release a migration landed in, this could have been useful.

I wrote this in Go rather than bash because I prefer golang.

How to use it?

Find all migrations between 2 versions

Going from 2.3.0 to 2.4.0

$ go run scripts/releasemigrations/main.go --list --versions=v2.3.0,v2.4.0                                                                                                       11:47:00 AM
2023/11/21 11:47:09 [minor] 4 migrations added between v2.3.0 and v2.4.0
2023/11/21 11:47:09     coderd/database/migrations/000165_prevent_autostart_days.up.sql
2023/11/21 11:47:09     coderd/database/migrations/000166_template_active_version.up.sql
2023/11/21 11:47:09     coderd/database/migrations/000167_workspace_agent_api_version.up.sql
2023/11/21 11:47:09     coderd/database/migrations/000168_pg_coord_tailnet_v2_api.up.sql
2023/11/21 11:47:09 Patches: 0 (0 with migrations)
2023/11/21 11:47:09 Minors: 1 (1 with migrations)
2023/11/21 11:47:09 Majors: 0 (0 with migrations)

Looking at all patch releases after v2

$ go run scripts/releasemigrations/main.go --patches --after-v2                                                                                                                  11:47:09 AM
2023/11/21 11:48:00 [patch] No migrations added between v2.0.0 and v2.0.1
2023/11/21 11:48:00 [patch] 2 migrations added between v2.0.1 and v2.0.2
2023/11/21 11:48:00 [patch] No migrations added between v2.1.0 and v2.1.1
2023/11/21 11:48:00 [patch] No migrations added between v2.1.1 and v2.1.2
2023/11/21 11:48:00 [patch] No migrations added between v2.1.2 and v2.1.3
2023/11/21 11:48:00 [patch] 1 migrations added between v2.1.3 and v2.1.4
2023/11/21 11:48:00 [patch] 2 migrations added between v2.1.4 and v2.1.5
2023/11/21 11:48:00 [patch] 1 migrations added between v2.3.0 and v2.3.1
2023/11/21 11:48:00 [patch] 1 migrations added between v2.3.1 and v2.3.2
2023/11/21 11:48:00 [patch] 1 migrations added between v2.3.2 and v2.3.3
2023/11/21 11:48:00 Patches: 10 (6 with migrations)
2023/11/21 11:48:00 Minors: 4 (4 with migrations)
2023/11/21 11:48:00 Majors: 0 (0 with migrations)

Seeing all the noise this thing can make

This shows when every migration was introduced.

$ go run scripts/releasemigrations/main.go --patches --minors --majors --list 
# ...
2023/11/21 11:48:31 [minor] 5 migrations added between v2.2.1 and v2.3.0
2023/11/21 11:48:31     coderd/database/migrations/000160_provisioner_job_status.up.sql
2023/11/21 11:48:31     coderd/database/migrations/000161_workspace_agent_stats_template_id_created_at_user_id_include_sessions.up.sql
2023/11/21 11:48:31     coderd/database/migrations/000162_workspace_automatic_updates.up.sql
2023/11/21 11:48:31     coderd/database/migrations/000163_external_auth_extra.up.sql
2023/11/21 11:48:31     coderd/database/migrations/000164_archive_template_versions.up.sql
2023/11/21 11:48:31 [patch] 1 migrations added between v2.3.0 and v2.3.1
2023/11/21 11:48:31     coderd/database/migrations/000165_prevent_autostart_days.up.sql
2023/11/21 11:48:31 [patch] 1 migrations added between v2.3.1 and v2.3.2
2023/11/21 11:48:31     coderd/database/migrations/000166_template_active_version.up.sql
2023/11/21 11:48:31 [patch] 1 migrations added between v2.3.2 and v2.3.3
2023/11/21 11:48:31     coderd/database/migrations/000167_workspace_agent_api_version.up.sql
2023/11/21 11:48:31 [minor] 1 migrations added between v2.3.3 and v2.4.0
2023/11/21 11:48:31     coderd/database/migrations/000168_pg_coord_tailnet_v2_api.up.sql
2023/11/21 11:48:31 Patches: 122 (55 with migrations)
2023/11/21 11:48:31 Minors: 31 (26 with migrations)
2023/11/21 11:48:31 Majors: 1 (1 with migrations)

@Emyrk Emyrk requested a review from kylecarbs November 21, 2023 22:28
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is useful for sure.
Add a README.md and :shipit:

@Emyrk Emyrk removed the request for review from kylecarbs November 27, 2023 15:57
@Emyrk Emyrk merged commit 20525c8 into main Nov 27, 2023
@Emyrk Emyrk deleted the stevenmasley/database_mig_releases branch November 27, 2023 16:53
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants