diff --git a/Documentation/pgm-MigrateAccountPatchReviewDb.txt b/Documentation/pgm-MigrateAccountPatchReviewDb.txt index 5718a8a5e1..c8ab19380c 100644 --- a/Documentation/pgm-MigrateAccountPatchReviewDb.txt +++ b/Documentation/pgm-MigrateAccountPatchReviewDb.txt @@ -27,6 +27,12 @@ To migrate AccountPatchReviewDb: * Migrate data using this command * Start Gerrit +[NOTE] +When using MySQL, the file_name column length in the account_patch_reviews table will be shortened +from the standard 4096 characters down to 255 characters. This is due to a +link:https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html[MySQL limitation] +on the max size of 767 bytes for each column in an index. + == OPTIONS -d:: diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java index c274e56900..43f39b29d7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java @@ -181,7 +181,7 @@ public abstract class JdbcAccountPatchReviewStore } } - private static void doCreateTable(Statement stmt) throws SQLException { + protected void doCreateTable(Statement stmt) throws SQLException { stmt.executeUpdate( "CREATE TABLE IF NOT EXISTS account_patch_reviews (" + "account_id INTEGER DEFAULT 0 NOT NULL, " diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java index af844656e6..d648ed0672 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java @@ -22,6 +22,7 @@ import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.SQLException; +import java.sql.Statement; import org.eclipse.jgit.lib.Config; @Singleton @@ -50,4 +51,17 @@ public class MysqlAccountPatchReviewStore extends JdbcAccountPatchReviewStore { return new OrmException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); } } + + @Override + protected void doCreateTable(Statement stmt) throws SQLException { + stmt.executeUpdate( + "CREATE TABLE IF NOT EXISTS account_patch_reviews (" + + "account_id INTEGER DEFAULT 0 NOT NULL, " + + "change_id INTEGER DEFAULT 0 NOT NULL, " + + "patch_set_id INTEGER DEFAULT 0 NOT NULL, " + + "file_name VARCHAR(255) DEFAULT '' NOT NULL, " + + "CONSTRAINT primary_key_account_patch_reviews " + + "PRIMARY KEY (change_id, patch_set_id, account_id, file_name)" + + ")"); + } }