Add credential_type to import_sync_repositories

What does this MR do and why?

Adds a credential_type column to import_sync_repositories so a sync repository records how it authenticates to GitHub: oauth (0) or personal_access_token (1).

This is the schema-only first step of continuous sync with a personal access token, tracked in #634424 (closed). It changes no behavior. Every existing row defaults to oauth, which is how all current sync repositories were connected, and nothing reads or writes the new column yet. MR 2 uses it to create and handle PAT repositories.

The type is stored explicitly instead of being inferred from import data. A missing or cleared import data row must never turn an OAuth repository into a PAT one.

Relates to #634424 (closed)

Changes

  • Migration: db/migrate/20261112094317_add_credential_type_to_import_sync_repositories.rb adds credential_type as smallint, default: 0, null: false. Milestone 19.6.
  • Schema: db/structure.sql and db/schema_migrations/20261112094317.
  • Model: enum :credential_type, { oauth: 0, personal_access_token: 1 } in Import::Sync::Repository. There is no prefix. I checked for collisions with existing oauth? and personal_access_token? methods and found none.
  • Factory: a :personal_access_token trait.
  • Specs: a credential type block in ee/spec/models/import/sync/repository_spec.rb. It covers the enum values, the column default and NOT NULL, persistence, the :oauth trait, and restore! leaving the type unchanged.

Database

Adding a column with a constant default is a metadata-only change on current PostgreSQL, so it does not rewrite the table. The column is not indexed or used in queries, so there are no query plans to attach.

Migration up
main: == [advisory_lock_connection] object_id: 59248, pg_backend_pid: 15171
main: == 20261112094317 AddCredentialTypeToImportSyncRepositories: migrating ========
main: -- add_column(:import_sync_repositories, :credential_type, :smallint, {default: 0, null: false})
main:    -> 0.0234s
main: == 20261112094317 AddCredentialTypeToImportSyncRepositories: migrated (0.0289s) 

main: == [advisory_lock_connection] object_id: 59248, pg_backend_pid: 15171 
Migration down
main: == [advisory_lock_connection] object_id: 60504, pg_backend_pid: 95973
main: == 20261112094317 AddCredentialTypeToImportSyncRepositories: reverting ========
main: -- remove_column(:import_sync_repositories, :credential_type, :smallint, {default: 0, null: false})
main:    -> 0.1481s
main: == 20261112094317 AddCredentialTypeToImportSyncRepositories: reverted (0.1619s) 

main: == [advisory_lock_connection] object_id: 60504, pg_backend_pid: 95973```

</details>
## MR acceptance checklist

Evaluate this MR against the [MR acceptance checklist](https://docs.gitlab.com/development/code_review/#acceptance-checklist).
It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

/assign me


Related to #634424

Merge request reports

Loading
Loading