Skip to content

Conversation

@deiga
Copy link
Collaborator

@deiga deiga commented Jan 7, 2026

Supersedes #3018


Before the change?

  • Schema Migrations used MigrateState which is from 0.11 of the SDK
  • Converted resources:
    • github_actions_organization_secret
    • github_actions_secret
    • github_repository_webhook
    • github_repository

After the change?

  • Schema Migrations use StateUpgraders which is the default since 0.12 of the SDK

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Copy link
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Could we move the migration code into the resource files instead of having it in separate files which makes it significantly harder to reason about?

@stevehipwell stevehipwell added this to the v6.10.0 Release milestone Jan 8, 2026
@stevehipwell stevehipwell added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label Jan 8, 2026
@nickfloyd
Copy link
Member

Could we move the migration code into the resource files instead of having it in separate files which makes it significantly harder to reason about?

We can definitely do that - I'd recommend that we follow up with changing the existing ones as well so that we have a consistent pattern.

@stevehipwell
Copy link
Collaborator

@nickfloyd I think this PR is modifying all of the existing ones, so I was meaning for all migrations to be located next to the relevant schemas.

@nickfloyd
Copy link
Member

@stevehipwell That makes so much more sense... thank you for the clarity.

@deiga
Copy link
Collaborator Author

deiga commented Jan 8, 2026

@nickfloyd @stevehipwell I'm honestly not sure about merging the migration files with the resource files

Some of these migration files are very long and since they contain Schemas at specific points in time it could make it confusing to have multiple schema in the same file. Or would we keep the schemas still in separate files and only move the state upgrade functions to the resource files?

@stevehipwell
Copy link
Collaborator

What about adding schema files with the same name as the primary files and then adding a schema suffix so they're at least located next to each other? For example github_resource_foo.go & github_resource_foo_schema.go

@nickfloyd
Copy link
Member

@stevehipwell I'm wondering if this would be a good move for 7.x. I really like the idea of a related grouping so for instance our protocol would be:

github_[resource]_[function].go

So, given something like: branch_protection, like you were sketching out, you'd have:

  • github_branch_protection_migrate.go
  • github_branch_protection_resource.go
  • github_branch_protection_resource_test.go
  • github_branch_protection_data_source.go
  • github_branch_protection_data_source_test.go

Is that what you were thinking? If so I can write up an issue for us to rework all of that.

@deiga deiga force-pushed the upgrade-state-migrations branch from 6fc64f6 to 710d9b8 Compare January 8, 2026 20:44
@deiga
Copy link
Collaborator Author

deiga commented Jan 8, 2026

@stevehipwell Something like this? 710d9b8 (#3065)

@stevehipwell
Copy link
Collaborator

@deiga do you mean the code or file paths?

@nickfloyd for v7 I'd suggest aligning to a more idiomatic approach like below. But for now I'd really like to see the migration code moved as it's all being modified.

  • internal/provider/data_repository.go
  • internal/provider/data_repository_schema.go
  • internal/provider/data_repository_test.go
  • internal/provider/repository.go
  • internal/provider/repository_schema.go
  • internal/provider/repository_test.go

@deiga
Copy link
Collaborator Author

deiga commented Jan 8, 2026

@stevehipwell Both? Just wanted to double check if this close enough to what you had in mind, before I do the same change for every migration file

@stevehipwell
Copy link
Collaborator

@stevehipwell Both? Just wanted to double check if this close enough to what you had in mind, before I do the same change for every migration file

I was on my phone so it was hard to figure out what had changed.

OK, how about github/resource_github_actions_secret_migration.go (& github/resource_github_actions_secret_migration_test.go) with the migration functions and the schemas in the one file? I think this will meet my desire for keeping the code together without adding additional complexity to the main files. Also after thinking it through carefully I realized that once the migration has happened the code is effectively meaningless so should be kept out of the way for general readability.

@deiga deiga requested a review from stevehipwell January 10, 2026 21:02
@deiga deiga force-pushed the upgrade-state-migrations branch 2 times, most recently from 04ae654 to c4fd2a4 Compare January 13, 2026 20:05
Copy link
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

The code changes look great, I've just added a comment suggesting a change to the way that the migration function tests are structured.

Copy link
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

LGTM

@stevehipwell
Copy link
Collaborator

@deiga could you please rebase this PR?

deiga added 8 commits January 15, 2026 22:23
…ers` for schema migrations

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…ema migrations

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…tionWebhook` schema migrations to use StateUpgraders

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…ders

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…artion_test.go file

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Rename migrate_github_actions_organization_secret*.go to
resource_github_actions_organization_secret_migration*.go for
consistent naming with resource files.
deiga added 8 commits January 15, 2026 22:23
Rename migrate_github_branch_protection.go to
resource_github_branch_protection_migration.go for
consistent naming with resource files.
Rename migrate_github_organization_webhook*.go to
resource_github_organization_webhook_migration*.go for
consistent naming with resource files.
Rename migrate_github_repository*.go to
resource_github_repository_migration*.go for
consistent naming with resource files.
Rename migrate_github_repository_webhook*.go to
resource_github_repository_webhook_migration*.go for
consistent naming with resource files.
Migrate resource_github_actions_secret.go from legacy CRUD functions
to Context-aware functions (CreateContext, ReadContext, DeleteContext).

- Add diag import
- Update function signatures to accept context.Context
- Return diag.Diagnostics instead of error
- Use StateContext for importer

Ref: integrations#2996
Migrate resource_github_actions_organization_secret.go from legacy
CRUD to context-aware CRUD functions (CreateContext, ReadContext,
DeleteContext) per Terraform Plugin SDK v2 best practices.

Ref: integrations#2996
Migrate resource_github_organization_webhook.go from legacy CRUD to
context-aware CRUD functions (CreateContext, ReadContext, UpdateContext,
DeleteContext) per Terraform Plugin SDK v2 best practices.

Ref: integrations#2996
Migrate resource_github_repository_webhook.go from legacy CRUD to
context-aware CRUD functions (CreateContext, ReadContext, UpdateContext,
DeleteContext) per Terraform Plugin SDK v2 best practices.

Ref: integrations#2996
@deiga deiga force-pushed the upgrade-state-migrations branch from c4fd2a4 to 8b6a21f Compare January 15, 2026 20:24
@stevehipwell stevehipwell merged commit 1dfeffe into integrations:main Jan 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants