Increase allowed length for user token in db (#328)

After update to latest version gitea and use oauth, gitea returns long token in my case it was >800 characters. DB schema of the table has varchar(500), I updated it to varchar(1000) to solve the problem.

* Fix length for gitea token/secret
This commit is contained in:
Veniamin Gvozdikov 2021-09-21 19:39:09 +03:00 committed by GitHub
parent 7f4a205764
commit 4fd8a1ef42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 0 deletions

View file

@ -208,6 +208,10 @@ var migrations = []struct {
name: "drop-allow-push-tags-deploys-columns",
stmt: dropAllowPushTagsDeploysColumns,
},
{
name: "update-table-set-users-token-and-secret-length",
stmt: updateTableSetUsersTokenAndSecretLength,
},
}
// Migrate performs the database migration. If the migration fails
@ -769,3 +773,11 @@ ALTER TABLE repos DROP COLUMN repo_fallback
var dropAllowPushTagsDeploysColumns = `
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
`
//
// 028_update_table_set_users_token_and_secret_length.sql
//
var updateTableSetUsersTokenAndSecretLength = `
ALTER TABLE users MODIFY user_token varchar(1000), MODIFY user_secret varchar(1000);
`

View file

@ -0,0 +1,3 @@
-- name: update-table-set-users-token-and-secret-length
ALTER TABLE users MODIFY user_token varchar(1000), MODIFY user_secret varchar(1000);

View file

@ -208,6 +208,10 @@ var migrations = []struct {
name: "drop-allow-push-tags-deploys-columns",
stmt: dropAllowPushTagsDeploysColumns,
},
{
name: "update-table-set-users-token-and-secret-length",
stmt: updateTableSetUsersTokenAndSecretLength,
},
}
// Migrate performs the database migration. If the migration fails
@ -771,3 +775,12 @@ ALTER TABLE repos DROP COLUMN repo_fallback
var dropAllowPushTagsDeploysColumns = `
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
`
//
// 028_update_table_set_users_token_and_secret_length.sql
//
var updateTableSetUsersTokenAndSecretLength = `
ALTER TABLE users ALTER COLUMN user_token TYPE varchar(1000);
ALTER TABLE users ALTER COLUMN user_secret TYPE varchar(1000);
`

View file

@ -0,0 +1,4 @@
-- name: update-table-set-users-token-and-secret-length
ALTER TABLE users ALTER COLUMN user_token TYPE varchar(1000);
ALTER TABLE users ALTER COLUMN user_secret TYPE varchar(1000);

View file

@ -212,6 +212,10 @@ var migrations = []struct {
name: "drop-allow-push-tags-deploys-columns",
stmt: dropAllowPushTagsDeploysColumns,
},
{
name: "update-table-set-users-token-and-secret-length",
stmt: updateTableSetUsersTokenAndSecretLength,
},
}
// Migrate performs the database migration. If the migration fails
@ -870,3 +874,11 @@ DROP TABLE repos;
ALTER TABLE repos_new RENAME TO repos;
COMMIT;
`
//
// 028_update_table_set_users_token_and_secret_length.sql
//
var updateTableSetUsersTokenAndSecretLength = `
`

View file

@ -0,0 +1,3 @@
-- name: update-table-set-users-token-and-secret-length
-- noop since sqlite do use TEXT