@@ -77,6 +77,27 @@ public function run(IOutput $output) {
7777 $ schema = new SchemaWrapper ($ this ->db );
7878 $ table = $ schema ->getTable ('oauth2_clients ' );
7979 if ($ table ->getColumn ('name ' )->getLength () !== 64 ) {
80+ // shorten existing values before resizing the column
81+ $ qb = $ this ->db ->getQueryBuilder ();
82+ $ qb ->update ('oauth2_clients ' )
83+ ->set ('name ' , $ qb ->createParameter ('shortenedName ' ))
84+ ->where ($ qb ->expr ()->eq ('id ' , $ qb ->createParameter ('theId ' )));
85+
86+ $ qbSelect = $ this ->db ->getQueryBuilder ();
87+ $ qbSelect ->select ('id ' , 'name ' )
88+ ->from ('oauth2_clients ' );
89+
90+ $ result = $ qbSelect ->executeQuery ();
91+ while ($ row = $ result ->fetch ()) {
92+ $ id = $ row ['id ' ];
93+ $ shortenedName = mb_substr ($ row ['name ' ], 0 , 64 );
94+ $ qb ->setParameter ('theId ' , $ id , IQueryBuilder::PARAM_INT );
95+ $ qb ->setParameter ('shortenedName ' , $ shortenedName , IQueryBuilder::PARAM_STR );
96+ $ qb ->executeStatement ();
97+ }
98+ $ result ->closeCursor ();
99+
100+ // safely set the new column length
80101 $ table ->getColumn ('name ' )->setLength (64 );
81102 }
82103 if ($ table ->hasColumn ('allow_subdomains ' )) {
0 commit comments