From 0d99bfc838546d00f656f723f6a1cd3e41111bcc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 14:49:12 +0000 Subject: [PATCH 1/4] Initial plan From 51f3d3d73bff20a636be81a91e99173561767dae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 14:52:36 +0000 Subject: [PATCH 2/4] Add migration to update OAuth token column from VARCHAR(255) to TEXT Co-authored-by: ifox <708498+ifox@users.noreply.github.com> --- ...000001_update_twill_oauth_token_column.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php diff --git a/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php new file mode 100644 index 0000000000..9e55781009 --- /dev/null +++ b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php @@ -0,0 +1,44 @@ +text('token')->change(); + }); + } + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + if (config('twill.enabled.users-oauth', false)) { + $twillOauthTable = config('twill.users_oauth_table', 'twill_users_oauth'); + + if (Schema::hasTable($twillOauthTable) && Schema::hasColumn($twillOauthTable, 'token')) { + Schema::table($twillOauthTable, function (Blueprint $table) { + $table->string('token')->change(); + }); + } + } + } +}; From 7a9c38eeac2e9e1ed5dc5a9664d86a911ccdc235 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 14:54:49 +0000 Subject: [PATCH 3/4] Add safety check to prevent data loss on migration rollback Co-authored-by: ifox <708498+ifox@users.noreply.github.com> --- ...17_000001_update_twill_oauth_token_column.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php index 9e55781009..0ef9840039 100644 --- a/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php +++ b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php @@ -2,6 +2,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration @@ -27,6 +28,9 @@ public function up() /** * Reverse the migrations. * + * Note: Rolling back this migration may truncate tokens longer than 255 characters. + * Ensure no tokens exceed this length before rolling back. + * * @return void */ public function down() @@ -35,6 +39,18 @@ public function down() $twillOauthTable = config('twill.users_oauth_table', 'twill_users_oauth'); if (Schema::hasTable($twillOauthTable) && Schema::hasColumn($twillOauthTable, 'token')) { + // Check if any tokens exceed 255 characters before rolling back + $longTokensCount = \DB::table($twillOauthTable) + ->whereRaw('LENGTH(token) > 255') + ->count(); + + if ($longTokensCount > 0) { + throw new \RuntimeException( + "Cannot rollback migration: {$longTokensCount} token(s) exceed 255 characters. " . + "Please truncate or remove these tokens before rolling back this migration." + ); + } + Schema::table($twillOauthTable, function (Blueprint $table) { $table->string('token')->change(); }); From d40a3242db93f648cba05d9428d6ad29f5480280 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 14:55:21 +0000 Subject: [PATCH 4/4] Use imported DB facade instead of global class Co-authored-by: ifox <708498+ifox@users.noreply.github.com> --- .../2026_01_17_000001_update_twill_oauth_token_column.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php index 0ef9840039..16b7aadfa7 100644 --- a/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php +++ b/migrations/optional/users-oauth/2026_01_17_000001_update_twill_oauth_token_column.php @@ -40,7 +40,7 @@ public function down() if (Schema::hasTable($twillOauthTable) && Schema::hasColumn($twillOauthTable, 'token')) { // Check if any tokens exceed 255 characters before rolling back - $longTokensCount = \DB::table($twillOauthTable) + $longTokensCount = DB::table($twillOauthTable) ->whereRaw('LENGTH(token) > 255') ->count();