Shorten column names that are longer than 30 characters

Some databases can't deal with column names that are longer than 30
characters. Examples are MaxDB and Oracle [1].

Gerrit has two column names in the accounts table that exceed the 30
characters: displayPatchSetsInReverseOrder,
displayPersonNameInReviewCategory

This change renames these 2 columns so that their names fit within
the 30 character range.

[1] http://groups.google.com/group/repo-discuss/browse_thread/thread/ecb713d42c04ae8a/cc963525d8247a17?lnk=gst#cc963525d8247a17

Change-Id: Ie58fb57bea5d5ec3634ad2a73241120a0e50a466
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-04-26 13:52:25 +02:00
parent bbc9de5ac8
commit f0540100d2
8 changed files with 84 additions and 38 deletions

View File

@@ -30,8 +30,8 @@ public interface AccountConstants extends Constants {
String showSiteHeader(); String showSiteHeader();
String useFlashClipboard(); String useFlashClipboard();
String copySelfOnEmails(); String copySelfOnEmails();
String displayPatchSetsInReverseOrder(); String reversePatchSetOrder();
String displayPersonNameInReviewCategory(); String showUsernameInReviewCategory();
String buttonSaveChanges(); String buttonSaveChanges();
String tabAccountSummary(); String tabAccountSummary();

View File

@@ -7,8 +7,8 @@ accountId = Account ID
showSiteHeader = Show Site Header showSiteHeader = Show Site Header
useFlashClipboard = Use Flash Clipboard Widget useFlashClipboard = Use Flash Clipboard Widget
copySelfOnEmails = CC Me On Comments I Write copySelfOnEmails = CC Me On Comments I Write
displayPatchSetsInReverseOrder = Display Patch Sets In Reverse Order reversePatchSetOrder = Display Patch Sets In Reverse Order
displayPersonNameInReviewCategory = Display Person Name In Review Category showUsernameInReviewCategory = Display Person Name In Review Category
defaultContextFieldLabel = Default Context: defaultContextFieldLabel = Default Context:
maximumPageSizeFieldLabel = Maximum Page Size: maximumPageSizeFieldLabel = Maximum Page Size:
dateFormatLabel = Date/Time Format: dateFormatLabel = Date/Time Format:

View File

@@ -41,8 +41,8 @@ public class MyPreferencesScreen extends SettingsScreen {
private CheckBox showSiteHeader; private CheckBox showSiteHeader;
private CheckBox useFlashClipboard; private CheckBox useFlashClipboard;
private CheckBox copySelfOnEmails; private CheckBox copySelfOnEmails;
private CheckBox displayPatchSetsInReverseOrder; private CheckBox reversePatchSetOrder;
private CheckBox displayPersonNameInReviewCategory; private CheckBox showUsernameInReviewCategory;
private ListBox maximumPageSize; private ListBox maximumPageSize;
private ListBox dateFormat; private ListBox dateFormat;
private ListBox timeFormat; private ListBox timeFormat;
@@ -74,11 +74,11 @@ public class MyPreferencesScreen extends SettingsScreen {
copySelfOnEmails = new CheckBox(Util.C.copySelfOnEmails()); copySelfOnEmails = new CheckBox(Util.C.copySelfOnEmails());
copySelfOnEmails.addClickHandler(onClickSave); copySelfOnEmails.addClickHandler(onClickSave);
displayPatchSetsInReverseOrder = new CheckBox(Util.C.displayPatchSetsInReverseOrder()); reversePatchSetOrder = new CheckBox(Util.C.reversePatchSetOrder());
displayPatchSetsInReverseOrder.addClickHandler(onClickSave); reversePatchSetOrder.addClickHandler(onClickSave);
displayPersonNameInReviewCategory = new CheckBox(Util.C.displayPersonNameInReviewCategory()); showUsernameInReviewCategory = new CheckBox(Util.C.showUsernameInReviewCategory());
displayPersonNameInReviewCategory.addClickHandler(onClickSave); showUsernameInReviewCategory.addClickHandler(onClickSave);
maximumPageSize = new ListBox(); maximumPageSize = new ListBox();
for (final short v : PAGESIZE_CHOICES) { for (final short v : PAGESIZE_CHOICES) {
@@ -137,11 +137,11 @@ public class MyPreferencesScreen extends SettingsScreen {
row++; row++;
formGrid.setText(row, labelIdx, ""); formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, displayPatchSetsInReverseOrder); formGrid.setWidget(row, fieldIdx, reversePatchSetOrder);
row++; row++;
formGrid.setText(row, labelIdx, ""); formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, displayPersonNameInReviewCategory); formGrid.setWidget(row, fieldIdx, showUsernameInReviewCategory);
row++; row++;
formGrid.setText(row, labelIdx, Util.C.maximumPageSizeFieldLabel()); formGrid.setText(row, labelIdx, Util.C.maximumPageSizeFieldLabel());
@@ -179,8 +179,8 @@ public class MyPreferencesScreen extends SettingsScreen {
showSiteHeader.setEnabled(on); showSiteHeader.setEnabled(on);
useFlashClipboard.setEnabled(on); useFlashClipboard.setEnabled(on);
copySelfOnEmails.setEnabled(on); copySelfOnEmails.setEnabled(on);
displayPatchSetsInReverseOrder.setEnabled(on); reversePatchSetOrder.setEnabled(on);
displayPersonNameInReviewCategory.setEnabled(on); showUsernameInReviewCategory.setEnabled(on);
maximumPageSize.setEnabled(on); maximumPageSize.setEnabled(on);
dateFormat.setEnabled(on); dateFormat.setEnabled(on);
timeFormat.setEnabled(on); timeFormat.setEnabled(on);
@@ -190,8 +190,8 @@ public class MyPreferencesScreen extends SettingsScreen {
showSiteHeader.setValue(p.isShowSiteHeader()); showSiteHeader.setValue(p.isShowSiteHeader());
useFlashClipboard.setValue(p.isUseFlashClipboard()); useFlashClipboard.setValue(p.isUseFlashClipboard());
copySelfOnEmails.setValue(p.isCopySelfOnEmails()); copySelfOnEmails.setValue(p.isCopySelfOnEmails());
displayPatchSetsInReverseOrder.setValue(p.isDisplayPatchSetsInReverseOrder()); reversePatchSetOrder.setValue(p.isReversePatchSetOrder());
displayPersonNameInReviewCategory.setValue(p.isDisplayPersonNameInReviewCategory()); showUsernameInReviewCategory.setValue(p.isShowUsernameInReviewCategory());
setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.getMaximumPageSize()); setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.getMaximumPageSize());
setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, // setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, //
p.getDateFormat()); p.getDateFormat());
@@ -251,8 +251,8 @@ public class MyPreferencesScreen extends SettingsScreen {
p.setShowSiteHeader(showSiteHeader.getValue()); p.setShowSiteHeader(showSiteHeader.getValue());
p.setUseFlashClipboard(useFlashClipboard.getValue()); p.setUseFlashClipboard(useFlashClipboard.getValue());
p.setCopySelfOnEmails(copySelfOnEmails.getValue()); p.setCopySelfOnEmails(copySelfOnEmails.getValue());
p.setDisplayPatchSetsInReverseOrder(displayPatchSetsInReverseOrder.getValue()); p.setReversePatchSetOrder(reversePatchSetOrder.getValue());
p.setDisplayPersonNameInReviewCategory(displayPersonNameInReviewCategory.getValue()); p.setShowUsernameInReviewCategory(showUsernameInReviewCategory.getValue());
p.setMaximumPageSize(getListBox(maximumPageSize, DEFAULT_PAGESIZE)); p.setMaximumPageSize(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
p.setDateFormat(getListBox(dateFormat, p.setDateFormat(getListBox(dateFormat,
AccountGeneralPreferences.DateFormat.STD, AccountGeneralPreferences.DateFormat.STD,

View File

@@ -286,13 +286,13 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
int col = BASE_COLUMNS; int col = BASE_COLUMNS;
boolean haveReview = false; boolean haveReview = false;
boolean displayPersonNameInReviewCategory = false; boolean showUsernameInReviewCategory = false;
if (Gerrit.isSignedIn()) { if (Gerrit.isSignedIn()) {
AccountGeneralPreferences prefs = Gerrit.getUserAccount().getGeneralPreferences(); AccountGeneralPreferences prefs = Gerrit.getUserAccount().getGeneralPreferences();
if (prefs.isDisplayPersonNameInReviewCategory()) { if (prefs.isShowUsernameInReviewCategory()) {
displayPersonNameInReviewCategory = true; showUsernameInReviewCategory = true;
} }
} }
@@ -314,7 +314,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
if (type.isMaxNegative(ca)) { if (type.isMaxNegative(ca)) {
if (displayPersonNameInReviewCategory) { if (showUsernameInReviewCategory) {
FlowPanel fp = new FlowPanel(); FlowPanel fp = new FlowPanel();
fp.add(new Image(Gerrit.RESOURCES.redNot())); fp.add(new Image(Gerrit.RESOURCES.redNot()));
fp.add(new InlineLabel(FormatUtil.name(ai))); fp.add(new InlineLabel(FormatUtil.name(ai)));
@@ -325,7 +325,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
} else if (type.isMaxPositive(ca)) { } else if (type.isMaxPositive(ca)) {
if (displayPersonNameInReviewCategory) { if (showUsernameInReviewCategory) {
FlowPanel fp = new FlowPanel(); FlowPanel fp = new FlowPanel();
fp.add(new Image(Gerrit.RESOURCES.greenCheck())); fp.add(new Image(Gerrit.RESOURCES.greenCheck()));
fp.add(new InlineLabel(FormatUtil.name(ai))); fp.add(new InlineLabel(FormatUtil.name(ai)));
@@ -337,7 +337,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
} else { } else {
String vstr = String.valueOf(ca.getValue()); String vstr = String.valueOf(ca.getValue());
if (displayPersonNameInReviewCategory) { if (showUsernameInReviewCategory) {
vstr = vstr + " " + FormatUtil.name(ai); vstr = vstr + " " + FormatUtil.name(ai);
} }

View File

@@ -79,7 +79,7 @@ public class PatchSetsBlock extends Composite {
if (Gerrit.isSignedIn()) { if (Gerrit.isSignedIn()) {
final AccountGeneralPreferences p = final AccountGeneralPreferences p =
Gerrit.getUserAccount().getGeneralPreferences(); Gerrit.getUserAccount().getGeneralPreferences();
if (p.isDisplayPatchSetsInReverseOrder()) { if (p.isReversePatchSetOrder()) {
Collections.reverse(patchSets); Collections.reverse(patchSets);
} }
} }

View File

@@ -118,10 +118,10 @@ public final class AccountGeneralPreferences {
* (show latest patch set on top). * (show latest patch set on top).
*/ */
@Column(id = 10) @Column(id = 10)
protected boolean displayPatchSetsInReverseOrder; protected boolean reversePatchSetOrder;
@Column(id = 11) @Column(id = 11)
protected boolean displayPersonNameInReviewCategory; protected boolean showUsernameInReviewCategory;
public AccountGeneralPreferences() { public AccountGeneralPreferences() {
} }
@@ -188,20 +188,20 @@ public final class AccountGeneralPreferences {
copySelfOnEmail = includeSelfOnEmail; copySelfOnEmail = includeSelfOnEmail;
} }
public boolean isDisplayPatchSetsInReverseOrder() { public boolean isReversePatchSetOrder() {
return displayPatchSetsInReverseOrder; return reversePatchSetOrder;
} }
public void setDisplayPatchSetsInReverseOrder(final boolean displayPatchSetsInReverseOrder) { public void setReversePatchSetOrder(final boolean reversePatchSetOrder) {
this.displayPatchSetsInReverseOrder = displayPatchSetsInReverseOrder; this.reversePatchSetOrder = reversePatchSetOrder;
} }
public boolean isDisplayPersonNameInReviewCategory() { public boolean isShowUsernameInReviewCategory() {
return displayPersonNameInReviewCategory; return showUsernameInReviewCategory;
} }
public void setDisplayPersonNameInReviewCategory(final boolean displayPersonNameInReviewCategory) { public void setShowUsernameInReviewCategory(final boolean showUsernameInReviewCategory) {
this.displayPersonNameInReviewCategory = displayPersonNameInReviewCategory; this.showUsernameInReviewCategory = showUsernameInReviewCategory;
} }
public DateFormat getDateFormat() { public DateFormat getDateFormat() {
@@ -231,8 +231,8 @@ public final class AccountGeneralPreferences {
showSiteHeader = true; showSiteHeader = true;
useFlashClipboard = true; useFlashClipboard = true;
copySelfOnEmail = false; copySelfOnEmail = false;
displayPatchSetsInReverseOrder = false; reversePatchSetOrder = false;
displayPersonNameInReviewCategory = false; showUsernameInReviewCategory = false;
downloadUrl = null; downloadUrl = null;
downloadCommand = null; downloadCommand = null;
dateFormat = null; dateFormat = null;

View File

@@ -32,7 +32,7 @@ import java.util.List;
/** A version of the database schema. */ /** A version of the database schema. */
public abstract class SchemaVersion { public abstract class SchemaVersion {
/** The current schema version. */ /** The current schema version. */
public static final Class<Schema_65> C = Schema_65.class; public static final Class<Schema_66> C = Schema_66.class;
public static class Module extends AbstractModule { public static class Module extends AbstractModule {
@Override @Override

View File

@@ -0,0 +1,46 @@
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.schema;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.sql.SQLException;
import java.sql.Statement;
public class Schema_66 extends SchemaVersion {
@Inject
Schema_66(Provider<Schema_65> prior) {
super(prior);
}
@Override
protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException {
final Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
try {
stmt.executeUpdate("UPDATE accounts SET reverse_patch_set_order = 'Y' "+
"WHERE display_patch_sets_in_reverse_order = 'Y'");
stmt.executeUpdate("UPDATE accounts SET show_username_in_review_category = 'Y' " +
"WHERE display_person_name_in_review_category = 'Y'");
} finally {
stmt.close();
}
}
}