summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2010-02-23 22:06:09 -0800
committerShawn O. Pearce <sop@google.com>2011-05-19 16:53:02 -0700
commit7c5d28a9a285a59ee65b3cee4b1bba0577720550 (patch)
tree186c1609658f53b1e007d2d7516001f4663f982e
parent89cefced8d0c9e2711dde756af52ffec56692417 (diff)
Remove schema upgrade 19 - 52
To simplify the migration changes I'm not going to try to support upgrading from schema 52 and earlier. Just kill the classes and require the user to upgrade to 2.1.7 first. Change-Id: Ic3199034addd2c6a17410745a80a58c1cd5ab8fc Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_19.java42
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_20.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_21.java74
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_22.java74
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_23.java61
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_24.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_25.java112
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_26.java47
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_27.java93
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_28.java101
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_29.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_30.java40
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_31.java41
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_32.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_33.java49
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_34.java123
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_35.java41
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_36.java51
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_37.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_38.java67
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_39.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_40.java70
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_41.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_42.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_43.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_44.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_45.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_46.java67
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_47.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_48.java54
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_49.java26
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_50.java25
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_51.java41
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_52.java20
34 files changed, 18 insertions, 1601 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_19.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_19.java
deleted file mode 100644
index 7ad91ff929..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_19.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (C) 2009 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.CurrentSchemaVersion;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.ProvisionException;
-
-class Schema_19 extends SchemaVersion {
- @Inject
- Schema_19() {
- super(new Provider<SchemaVersion>() {
- public SchemaVersion get() {
- throw new ProvisionException("Cannot upgrade from 18");
- }
- });
- }
-
- @Override
- protected void upgradeFrom(UpdateUI ui, CurrentSchemaVersion curr,
- ReviewDb db, boolean toTargetVersion) throws OrmException {
- throw new OrmException("Cannot upgrade from " + curr.versionNbr
- + "; manually run scripts from"
- + " http://gerrit.googlecode.com/files/schema-upgrades003_019.zip"
- + " and restart.");
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_20.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_20.java
deleted file mode 100644
index 4d8dca7f1d..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_20.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2009 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.inject.Inject;
-import com.google.inject.Provider;
-
-class Schema_20 extends SchemaVersion {
- @Inject
- Schema_20(Provider<Schema_19> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_21.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_21.java
deleted file mode 100644
index ed50f7fb9d..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_21.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2009 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.Project;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gerrit.reviewdb.SystemConfig;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectH2;
-import com.google.gwtorm.schema.sql.DialectMySQL;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collections;
-
-class Schema_21 extends SchemaVersion {
- @Inject
- Schema_21(Provider<Schema_20> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- JdbcSchema jdbc = (JdbcSchema) db;
- SystemConfig sc = db.systemConfig().get(new SystemConfig.Key());
-
- Statement s = jdbc.getConnection().createStatement();
- try {
- ResultSet r;
-
- r = s.executeQuery("SELECT name FROM projects WHERE project_id = 0");
- try {
- if (!r.next()) {
- throw new OrmException("Cannot read old wild project");
- }
- sc.wildProjectName = new Project.NameKey(r.getString(1));
- } finally {
- r.close();
- }
-
- if (jdbc.getDialect() instanceof DialectMySQL) {
- try {
- s.execute("DROP FUNCTION nextval_project_id");
- } catch (SQLException se) {
- ui.message("warning: could not delete function nextval_project_id");
- }
-
- } else if (jdbc.getDialect() instanceof DialectH2) {
- s.execute("ALTER TABLE projects DROP CONSTRAINT"
- + " IF EXISTS CONSTRAINT_F3");
- }
- } finally {
- s.close();
- }
-
- db.systemConfig().update(Collections.singleton(sc));
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_22.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_22.java
deleted file mode 100644
index 8e24aa2f0a..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_22.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2009 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 static com.google.gerrit.reviewdb.AccountExternalId.SCHEME_USERNAME;
-
-import com.google.gerrit.reviewdb.Account;
-import com.google.gerrit.reviewdb.AccountExternalId;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gerrit.reviewdb.AccountExternalId.Key;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectH2;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-
-class Schema_22 extends SchemaVersion {
- @Inject
- Schema_22(Provider<Schema_21> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- Statement s = ((JdbcSchema) db).getConnection().createStatement();
- try {
- ResultSet results =
- s.executeQuery(//
- "SELECT account_id, ssh_user_name"
- + " FROM accounts" //
- + " WHERE ssh_user_name IS NOT NULL"
- + " AND ssh_user_name <> ''");
- Collection<AccountExternalId> ids = new ArrayList<AccountExternalId>();
- while (results.next()) {
- final int accountId = results.getInt(1);
- final String userName = results.getString(2);
-
- final Account.Id account = new Account.Id(accountId);
- final AccountExternalId.Key key = toKey(userName);
- ids.add(new AccountExternalId(account, key));
- }
- db.accountExternalIds().insert(ids);
-
- if (((JdbcSchema) db).getDialect() instanceof DialectH2) {
- s.execute("ALTER TABLE accounts DROP CONSTRAINT"
- + " IF EXISTS CONSTRAINT_AF");
- }
- } finally {
- s.close();
- }
- }
-
- private Key toKey(final String userName) {
- return new AccountExternalId.Key(SCHEME_USERNAME, userName);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_23.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_23.java
deleted file mode 100644
index 413fa4e2c8..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_23.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2009 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.AccountGroup;
-import com.google.gerrit.reviewdb.AccountGroupName;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-
-class Schema_23 extends SchemaVersion {
- @Inject
- Schema_23(Provider<Schema_22> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- Collection<AccountGroupName> names = new ArrayList<AccountGroupName>();
- Statement queryStmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- ResultSet results =
- queryStmt.executeQuery("SELECT group_id, name FROM account_groups");
- while (results.next()) {
- final int id = results.getInt(1);
- final String name = results.getString(2);
-
- final AccountGroup.Id group = new AccountGroup.Id(id);
- final AccountGroup.NameKey key = toKey(name);
- names.add(new AccountGroupName(key, group));
- }
- } finally {
- queryStmt.close();
- }
- db.accountGroupNames().insert(names);
- }
-
- private AccountGroup.NameKey toKey(final String name) {
- return new AccountGroup.NameKey(name);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_24.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_24.java
deleted file mode 100644
index 0172921748..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_24.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-class Schema_24 extends SchemaVersion {
- @Inject
- Schema_24(Provider<Schema_23> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_25.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_25.java
deleted file mode 100644
index fdfff70398..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_25.java
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (C) 2010 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.AccountGroup;
-import com.google.gerrit.reviewdb.ApprovalCategory;
-import com.google.gerrit.reviewdb.Project;
-import com.google.gerrit.reviewdb.RefRight;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import org.eclipse.jgit.lib.Constants;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-class Schema_25 extends SchemaVersion {
- private Set<ApprovalCategory.Id> nonActions;
-
- @Inject
- Schema_25(Provider<Schema_24> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- nonActions = new HashSet<ApprovalCategory.Id>();
- for (ApprovalCategory c : db.approvalCategories().all()) {
- if (!c.isAction()) {
- nonActions.add(c.getId());
- }
- }
-
- List<RefRight> rights = new ArrayList<RefRight>();
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- ResultSet rs = stmt.executeQuery("SELECT * FROM project_rights");
- try {
- while (rs.next()) {
- rights.add(toRefRight(rs));
- }
- } finally {
- rs.close();
- }
-
- db.refRights().insert(rights);
- stmt.execute("CREATE INDEX ref_rights_byCatGroup"
- + " ON ref_rights (category_id, group_id)");
- } finally {
- stmt.close();
- }
- }
-
- private RefRight toRefRight(ResultSet rs) throws SQLException {
- short min_value = rs.getShort("min_value");
- short max_value = rs.getShort("max_value");
- String category_id = rs.getString("category_id");
- int group_id = rs.getInt("group_id");
- String project_name = rs.getString("project_name");
-
- ApprovalCategory.Id category = new ApprovalCategory.Id(category_id);
- Project.NameKey project = new Project.NameKey(project_name);
- AccountGroup.Id group = new AccountGroup.Id(group_id);
-
- RefRight.RefPattern ref;
- if (category.equals(ApprovalCategory.SUBMIT)
- || category.equals(ApprovalCategory.PUSH_HEAD)
- || nonActions.contains(category)) {
- // Explicitly related to a branch head.
- ref = new RefRight.RefPattern(Constants.R_HEADS + "*");
-
- } else if (category.equals(ApprovalCategory.PUSH_TAG)) {
- // Explicitly related to the tag namespace.
- ref = new RefRight.RefPattern(Constants.R_TAGS + "/*");
-
- } else if (category.equals(ApprovalCategory.READ)
- || category.equals(ApprovalCategory.OWN)) {
- // Currently these are project-wide rights, so apply that way.
- ref = new RefRight.RefPattern(RefRight.ALL);
-
- } else {
- // Assume project wide for the default.
- ref = new RefRight.RefPattern(RefRight.ALL);
- }
-
- RefRight.Key key = new RefRight.Key(project, ref, category, group);
- RefRight r = new RefRight(key);
- r.setMinValue(min_value);
- r.setMaxValue(max_value);
- return r;
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_26.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_26.java
deleted file mode 100644
index 9c76af20da..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_26.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2010 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.ReviewDb;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectMySQL;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-class Schema_26 extends SchemaVersion {
- @Inject
- Schema_26(Provider<Schema_25> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
- if (((JdbcSchema) db).getDialect() instanceof DialectMySQL) {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("ALTER TABLE account_group_members_audit" //
- + " MODIFY removed_on TIMESTAMP NULL DEFAULT NULL");
- stmt.execute("UPDATE account_group_members_audit" //
- + " SET removed_on = NULL" //
- + " WHERE removed_by IS NULL;");
- } finally {
- stmt.close();
- }
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_27.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_27.java
deleted file mode 100644
index f8febec998..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_27.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (C) 2010 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.AccountGroup;
-import com.google.gerrit.reviewdb.AccountGroupName;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectH2;
-import com.google.gwtorm.schema.sql.DialectMySQL;
-import com.google.gwtorm.schema.sql.DialectPostgreSQL;
-import com.google.gwtorm.schema.sql.SqlDialect;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-class Schema_27 extends SchemaVersion {
- @Inject
- Schema_27(Provider<Schema_26> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException, OrmException {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- final SqlDialect dialect = ((JdbcSchema) db).getDialect();
- if (dialect instanceof DialectPostgreSQL) {
- stmt.execute("ALTER TABLE account_groups"
- + " ALTER COLUMN name TYPE VARCHAR(255)");
- stmt.execute("ALTER TABLE account_group_names"
- + " ALTER COLUMN name TYPE VARCHAR(255)");
-
- } else if (dialect instanceof DialectH2) {
- stmt.execute("ALTER TABLE account_groups"
- + " ALTER COLUMN name VARCHAR(255)");
- stmt.execute("ALTER TABLE account_group_names"
- + " ALTER COLUMN name VARCHAR(255) NOT NULL");
-
- } else if (dialect instanceof DialectMySQL) {
- stmt.execute("ALTER TABLE account_groups MODIFY name VARCHAR(255)");
- stmt.execute("ALTER TABLE account_group_names"
- + " MODIFY name VARCHAR(255)");
-
- } else {
- throw new OrmException("Unsupported dialect " + dialect);
- }
- } finally {
- stmt.close();
- }
-
- // Some groups might be missing their names, our older schema
- // creation logic failed to create the name objects. Do it now.
- //
- Map<AccountGroup.NameKey, AccountGroupName> names =
- db.accountGroupNames().toMap(db.accountGroupNames().all());
-
- List<AccountGroupName> insert = new ArrayList<AccountGroupName>();
- List<AccountGroupName> update = new ArrayList<AccountGroupName>();
-
- for (AccountGroup g : db.accountGroups().all()) {
- AccountGroupName n = names.get(g.getNameKey());
- if (n == null) {
- insert.add(new AccountGroupName(g));
-
- } else if (!g.getId().equals(n.getId())) {
- n.setId(g.getId());
- update.add(n);
- }
- }
-
- db.accountGroupNames().insert(insert);
- db.accountGroupNames().update(update);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_28.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_28.java
deleted file mode 100644
index cddbe4e087..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_28.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (C) 2010 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.ApprovalCategory;
-import com.google.gerrit.reviewdb.ApprovalCategoryValue;
-import com.google.gerrit.reviewdb.RefRight;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gerrit.reviewdb.SystemConfig;
-import com.google.gerrit.server.workflow.NoOpFunction;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-
-class Schema_28 extends SchemaVersion {
- @Inject
- Schema_28(Provider<Schema_27> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- final SystemConfig cfg = db.systemConfig().get(new SystemConfig.Key());
- ApprovalCategory cat;
-
- initForgeIdentityCategory(db, cfg);
-
- // Don't grant FORGE_COMMITTER to existing PUSH_HEAD rights. That
- // is considered a bug that we are fixing with this schema upgrade.
- // Administrators might need to relax permissions manually after the
- // upgrade if that forgery is critical to their workflow.
-
- cat = db.approvalCategories().get(ApprovalCategory.PUSH_TAG);
- if (cat != null && "Push Annotated Tag".equals(cat.getName())) {
- cat.setName("Push Tag");
- db.approvalCategories().update(Collections.singleton(cat));
- }
-
- // Since we deleted Push Tags +3, drop anything using +3 down to +2.
- //
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("UPDATE ref_rights SET max_value = "
- + ApprovalCategory.PUSH_TAG_ANNOTATED + " WHERE max_value >= 3");
- stmt.execute("UPDATE ref_rights SET min_value = "
- + ApprovalCategory.PUSH_TAG_ANNOTATED + " WHERE min_value >= 3");
- } finally {
- stmt.close();
- }
- }
-
- private void initForgeIdentityCategory(final ReviewDb c,
- final SystemConfig sConfig) throws OrmException {
- final ApprovalCategory cat;
- final ArrayList<ApprovalCategoryValue> values;
-
- cat =
- new ApprovalCategory(ApprovalCategory.FORGE_IDENTITY, "Forge Identity");
- cat.setPosition((short) -1);
- cat.setFunctionName(NoOpFunction.NAME);
- values = new ArrayList<ApprovalCategoryValue>();
- values.add(value(cat, ApprovalCategory.FORGE_AUTHOR,
- "Forge Author Identity"));
- values.add(value(cat, ApprovalCategory.FORGE_COMMITTER,
- "Forge Committer or Tagger Identity"));
- c.approvalCategories().insert(Collections.singleton(cat));
- c.approvalCategoryValues().insert(values);
-
- RefRight right =
- new RefRight(new RefRight.Key(sConfig.wildProjectName,
- new RefRight.RefPattern(RefRight.ALL),
- ApprovalCategory.FORGE_IDENTITY, sConfig.registeredGroupId));
- right.setMinValue(ApprovalCategory.FORGE_AUTHOR);
- right.setMaxValue(ApprovalCategory.FORGE_AUTHOR);
- c.refRights().insert(Collections.singleton(right));
- }
-
- private static ApprovalCategoryValue value(final ApprovalCategory cat,
- final int value, final String name) {
- return new ApprovalCategoryValue(new ApprovalCategoryValue.Id(cat.getId(),
- (short) value), name);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_29.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_29.java
deleted file mode 100644
index 37920bfe06..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_29.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-class Schema_29 extends SchemaVersion {
- @Inject
- Schema_29(Provider<Schema_28> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_30.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_30.java
deleted file mode 100644
index 7285e322da..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_30.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2010 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.ApprovalCategory;
-import com.google.gerrit.reviewdb.ApprovalCategoryValue;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.util.Collections;
-
-class Schema_30 extends SchemaVersion {
- @Inject
- Schema_30(Provider<Schema_29> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
- db.approvalCategoryValues().insert(
- Collections.singleton(new ApprovalCategoryValue(
- new ApprovalCategoryValue.Id(ApprovalCategory.FORGE_IDENTITY,
- ApprovalCategory.FORGE_SERVER),
- "Forge Gerrit Code Review Server Identity")));
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_31.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_31.java
deleted file mode 100644
index 62f57e2109..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_31.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2010 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.ReviewDb;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-class Schema_31 extends SchemaVersion {
- @Inject
- Schema_31(Provider<Schema_30> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("CREATE INDEX changes_byProject"
- + " ON changes (dest_project_name)");
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_32.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_32.java
deleted file mode 100644
index 2af5596a47..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_32.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_32 extends SchemaVersion {
- @Inject
- Schema_32(Provider<Schema_31> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_33.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_33.java
deleted file mode 100644
index 0c733d71ea..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_33.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2010 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.AccountGroup;
-import com.google.gerrit.reviewdb.AccountGroupName;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gerrit.reviewdb.SystemConfig;
-import com.google.gwtorm.client.OrmException;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.util.Collections;
-
-public class Schema_33 extends SchemaVersion {
- @Inject
- Schema_33(Provider<Schema_32> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
- SystemConfig config = db.systemConfig().all().toList().get(0);
- final AccountGroup batchUsers =
- new AccountGroup(new AccountGroup.NameKey("Non-Interactive Users"),
- new AccountGroup.Id(db.nextAccountGroupId()));
- batchUsers.setDescription("Users who perform batch actions on Gerrit");
- batchUsers.setOwnerGroupId(config.adminGroupId);
- batchUsers.setType(AccountGroup.Type.INTERNAL);
- db.accountGroups().insert(Collections.singleton(batchUsers));
- db.accountGroupNames().insert(
- Collections.singleton(new AccountGroupName(batchUsers)));
-
- config.batchUsersGroupId = batchUsers.getId();
- db.systemConfig().update(Collections.singleton(config));
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_34.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_34.java
deleted file mode 100644
index fa94146c9c..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_34.java
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2010 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.ApprovalCategory;
-import com.google.gerrit.reviewdb.Project;
-import com.google.gerrit.reviewdb.RefRight;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gerrit.reviewdb.RefRight.RefPattern;
-import com.google.gerrit.server.project.RefControl.RefRightsForPattern;
-import com.google.gwtorm.client.OrmException;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Schema_34 extends SchemaVersion {
- private static final Comparator<String> DESCENDING_SORT =
- new Comparator<String>() {
-
- @Override
- public int compare(String a, String b) {
- int aLength = a.length();
- int bLength = b.length();
- if (bLength == aLength) {
- return a.compareTo(b);
- }
- return bLength - aLength;
- }
- };
-
- @Inject
- Schema_34(Provider<Schema_33> prior) {
- super(prior);
- }
-
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
- Iterable<Project> projects = db.projects().all();
- boolean showedBanner = false;
-
- List<RefRight> toUpdate = new ArrayList<RefRight>();
- List<RefRight> toDelete = new ArrayList<RefRight>();
- for (Project p : projects) {
- boolean showedProject = false;
- List<RefRight> pr = db.refRights().byProject(p.getNameKey()).toList();
- Map<ApprovalCategory.Id, Map<String, RefRightsForPattern>> r =
- new HashMap<ApprovalCategory.Id, Map<String, RefRightsForPattern>>();
- for (RefRight right : pr) {
- ApprovalCategory.Id cat = right.getApprovalCategoryId();
- if (r.get(cat) == null) {
- Map<String, RefRightsForPattern> m =
- new TreeMap<String, RefRightsForPattern>(DESCENDING_SORT);
- r.put(cat, m);
- }
- if (r.get(cat).get(right.getRefPattern()) == null) {
- RefRightsForPattern s = new RefRightsForPattern();
- r.get(cat).put(right.getRefPattern(), s);
- }
- r.get(cat).get(right.getRefPattern()).addRight(right);
- }
-
- for (Map<String, RefRightsForPattern> categoryRights : r.values()) {
- for (RefRightsForPattern rrp : categoryRights.values()) {
- RefRight oldRight = rrp.getRights().get(0);
- if (shouldPrompt(oldRight)) {
- if (!showedBanner) {
- ui.message("Entering interactive reference rights migration tool...");
- showedBanner = true;
- }
- if (!showedProject) {
- ui.message("In project " + p.getName());
- showedProject = true;
- }
- ui.message("For category " + oldRight.getApprovalCategoryId());
- boolean isWildcard = oldRight.getRefPattern().endsWith("/*");
- boolean shouldUpdate = ui.yesno(!isWildcard,
- "Should rights for pattern "
- + oldRight.getRefPattern()
- + " be considered exclusive?");
- if (shouldUpdate) {
- RefRight.Key newKey = new RefRight.Key(oldRight.getProjectNameKey(),
- new RefPattern("-" + oldRight.getRefPattern()),
- oldRight.getApprovalCategoryId(),
- oldRight.getAccountGroupId());
- RefRight newRight = new RefRight(newKey);
- newRight.setMaxValue(oldRight.getMaxValue());
- newRight.setMinValue(oldRight.getMinValue());
- toUpdate.add(newRight);
- toDelete.add(oldRight);
- }
- }
- }
- }
- }
- db.refRights().insert(toUpdate);
- db.refRights().delete(toDelete);
- }
-
- private boolean shouldPrompt(RefRight right) {
- return !right.getRefPattern().equals("refs/*")
- && !right.getRefPattern().equals("refs/heads/*")
- && !right.getRefPattern().equals("refs/tags/*");
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_35.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_35.java
deleted file mode 100644
index 12d90c3935..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_35.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2010 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.ReviewDb;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-public class Schema_35 extends SchemaVersion {
- @Inject
- Schema_35(Provider<Schema_34> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("CREATE INDEX tracking_ids_byTrkId"
- + " ON tracking_ids (tracking_id)");
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_36.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_36.java
deleted file mode 100644
index ba6b841f10..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_36.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2010 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.ReviewDb;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectMySQL;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-public class Schema_36 extends SchemaVersion {
- @Inject
- Schema_36(Provider<Schema_35> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- if (((JdbcSchema) db).getDialect() instanceof DialectMySQL) {
- stmt.execute("DROP INDEX account_project_watches_ntNew ON account_project_watches");
- stmt.execute("DROP INDEX account_project_watches_ntCmt ON account_project_watches");
- stmt.execute("DROP INDEX account_project_watches_ntSub ON account_project_watches");
- } else {
- stmt.execute("DROP INDEX account_project_watches_ntNew");
- stmt.execute("DROP INDEX account_project_watches_ntCmt");
- stmt.execute("DROP INDEX account_project_watches_ntSub");
- }
- stmt.execute("CREATE INDEX account_project_watches_byProject"
- + " ON account_project_watches (project_name)");
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_37.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_37.java
deleted file mode 100644
index 871f2e94bd..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_37.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_37 extends SchemaVersion {
- @Inject
- Schema_37(Provider<Schema_36> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_38.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_38.java
deleted file mode 100644
index 59d6fa24ea..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_38.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (C) 2010 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.Account;
-import com.google.gerrit.reviewdb.AccountDiffPreference;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Schema_38 extends SchemaVersion {
- @Inject
- Schema_38(Provider<Schema_37> prior) {
- super(prior);
- }
-
- /**
- * Migrate the account.default_context column to account_diff_preferences.context column.
- * <p>
- * Other fields in account_diff_preferences will be filled in with their defaults as
- * defined in the {@link AccountDiffPreference#createDefault(com.google.gerrit.reviewdb.Account.Id)}
- */
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException,
- SQLException {
- List<AccountDiffPreference> newPrefs =
- new ArrayList<AccountDiffPreference>();
-
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- ResultSet result =
- stmt.executeQuery("SELECT account_id, default_context"
- + " FROM accounts WHERE default_context <> 10");
- while (result.next()) {
- int accountId = result.getInt(1);
- short defaultContext = result.getShort(2);
- AccountDiffPreference diffPref = AccountDiffPreference.createDefault(new Account.Id(accountId));
- diffPref.setContext(defaultContext);
- newPrefs.add(diffPref);
- }
- } finally {
- stmt.close();
- }
-
- db.accountDiffPreferences().insert(newPrefs);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_39.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_39.java
deleted file mode 100644
index 39ae226c38..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_39.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_39 extends SchemaVersion {
- @Inject
- Schema_39(Provider<Schema_38> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_40.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_40.java
deleted file mode 100644
index 7d3e4f53b5..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_40.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2010 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.AccountProjectWatch;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.DialectH2;
-import com.google.gwtorm.schema.sql.DialectMySQL;
-import com.google.gwtorm.schema.sql.DialectPostgreSQL;
-import com.google.gwtorm.schema.sql.SqlDialect;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-public class Schema_40 extends SchemaVersion {
- @Inject
- Schema_40(Provider<Schema_39> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException,
- OrmException {
- // Set to "*" the filter field of the previously watched projects
- //
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("UPDATE account_project_watches" //
- + " SET filter = '" + AccountProjectWatch.FILTER_ALL + "'" //
- + " WHERE filter IS NULL OR filter = ''");
-
- // Set the new primary key
- //
- final SqlDialect dialect = ((JdbcSchema) db).getDialect();
- if (dialect instanceof DialectPostgreSQL) {
- stmt.execute("ALTER TABLE account_project_watches "
- + "DROP CONSTRAINT account_project_watches_pkey");
- stmt.execute("ALTER TABLE account_project_watches "
- + "ADD PRIMARY KEY (account_id, project_name, filter)");
-
- } else if ((dialect instanceof DialectH2)
- || (dialect instanceof DialectMySQL)) {
- stmt.execute("ALTER TABLE account_project_watches DROP PRIMARY KEY");
- stmt.execute("ALTER TABLE account_project_watches "
- + "ADD PRIMARY KEY (account_id, project_name, filter)");
-
- } else {
- throw new OrmException("Unsupported dialect " + dialect);
- }
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_41.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_41.java
deleted file mode 100644
index 508db43665..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_41.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_41 extends SchemaVersion {
- @Inject
- Schema_41(Provider<Schema_40> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_42.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_42.java
deleted file mode 100644
index 83bca7b837..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_42.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_42 extends SchemaVersion {
- @Inject
- Schema_42(Provider<Schema_41> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_43.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_43.java
deleted file mode 100644
index 0edb7e5ca3..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_43.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_43 extends SchemaVersion {
- @Inject
- Schema_43(Provider<Schema_42> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_44.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_44.java
deleted file mode 100644
index 4ab1986a72..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_44.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_44 extends SchemaVersion {
- @Inject
- Schema_44(Provider<Schema_43> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_45.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_45.java
deleted file mode 100644
index e37e87de01..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_45.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_45 extends SchemaVersion {
- @Inject
- Schema_45(Provider<Schema_44> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_46.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_46.java
deleted file mode 100644
index e7b104c3ea..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_46.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (C) 2010 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.AccountGroup;
-import com.google.gerrit.reviewdb.AccountGroupName;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collections;
-
-public class Schema_46 extends SchemaVersion {
-
- @Inject
- Schema_46(final Provider<Schema_45> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException,
- OrmException {
- AccountGroup.Id groupId = new AccountGroup.Id(db.nextAccountGroupId());
-
- // update system_config
- final Connection connection = ((JdbcSchema) db).getConnection();
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- stmt.execute("UPDATE system_config SET OWNER_GROUP_ID = " + groupId.get());
- final ResultSet resultSet =
- stmt.executeQuery("SELECT ADMIN_GROUP_ID FROM system_config");
- resultSet.next();
- final int adminGroupId = resultSet.getInt(1);
-
- // create 'Project Owners' group
- AccountGroup.NameKey nameKey = new AccountGroup.NameKey("Project Owners");
- AccountGroup group = new AccountGroup(nameKey, groupId);
- group.setType(AccountGroup.Type.SYSTEM);
- group.setOwnerGroupId(new AccountGroup.Id(adminGroupId));
- group.setDescription("Any owner of the project");
- AccountGroupName gn = new AccountGroupName(group);
- db.accountGroupNames().insert(Collections.singleton(gn));
- db.accountGroups().insert(Collections.singleton(group));
- } finally {
- if (stmt != null) stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_47.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_47.java
deleted file mode 100644
index 124cc0232c..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_47.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2010 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_47 extends SchemaVersion {
- @Inject
- Schema_47(Provider<Schema_46> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_48.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_48.java
deleted file mode 100644
index 4e8b94d6b5..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_48.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2010 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.ApprovalCategory;
-import com.google.gerrit.reviewdb.ApprovalCategoryValue;
-import com.google.gerrit.reviewdb.ReviewDb;
-import com.google.gwtorm.client.OrmException;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import java.util.Collections;
-
-public class Schema_48 extends SchemaVersion {
- @Inject
- Schema_48(Provider<Schema_47> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
- // Read +3 allows merges to be uploaded
- db.approvalCategoryValues().insert(
- Collections.singleton(new ApprovalCategoryValue(
- new ApprovalCategoryValue.Id(ApprovalCategory.READ, (short) 3),
- "Upload merges permission")));
- // Since we added Read +3, elevate any Read +2 to that level to provide
- // access equivalent to prior schema versions.
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("UPDATE ref_rights SET max_value = 3"
- + " WHERE category_id = '" + ApprovalCategory.READ.get()
- + "' AND max_value = 2");
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_49.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_49.java
deleted file mode 100644
index 0977ee9b95..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_49.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (C) 2011 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_49 extends SchemaVersion {
-
- @Inject
- Schema_49(Provider<Schema_48> prior) {
- super(prior);
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_50.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_50.java
deleted file mode 100644
index 4a90c1fd58..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_50.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2011 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.inject.Inject;
-import com.google.inject.Provider;
-
-public class Schema_50 extends SchemaVersion {
- @Inject
- Schema_50(Provider<Schema_49> prior) {
- super(prior);
- }
-} \ No newline at end of file
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_51.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_51.java
deleted file mode 100644
index d1111601c9..0000000000
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_51.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2011 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.ReviewDb;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import java.sql.SQLException;
-import java.sql.Statement;
-
-public class Schema_51 extends SchemaVersion {
- @Inject
- Schema_51(Provider<Schema_50> prior) {
- super(prior);
- }
-
- @Override
- protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
- Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
- try {
- stmt.execute("CREATE INDEX account_group_includes_byInclude"
- + " ON account_group_includes (include_id)");
- } finally {
- stmt.close();
- }
- }
-}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_52.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_52.java
index 3fbbbe0775..e16b95cb3e 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_52.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_52.java
@@ -14,12 +14,28 @@
package com.google.gerrit.server.schema;
+import com.google.gerrit.reviewdb.CurrentSchemaVersion;
+import com.google.gerrit.reviewdb.ReviewDb;
+import com.google.gwtorm.client.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
+import com.google.inject.ProvisionException;
public class Schema_52 extends SchemaVersion {
@Inject
- Schema_52(Provider<Schema_51> prior) {
- super(prior);
+ Schema_52() {
+ super(new Provider<SchemaVersion>() {
+ public SchemaVersion get() {
+ throw new ProvisionException("Cannot upgrade from 51");
+ }
+ });
+ }
+
+ @Override
+ protected void upgradeFrom(UpdateUI ui, CurrentSchemaVersion curr,
+ ReviewDb db, boolean toTargetVersion) throws OrmException {
+ throw new OrmException("Cannot upgrade from schema " + curr.versionNbr
+ + "; manually run init from Gerrit Code Review 2.1.7"
+ + " and restart this version to continue.");
}
}