Package com.google.gerrit.server.schema
Class SchemaVersion
- java.lang.Object
-
- com.google.gerrit.server.schema.SchemaVersion
-
- Direct Known Subclasses:
Schema_100
,Schema_101
,Schema_102
,Schema_103
,Schema_104
,Schema_105
,Schema_106
,Schema_107
,Schema_108
,Schema_109
,Schema_110
,Schema_111
,Schema_112
,Schema_113
,Schema_114
,Schema_115
,Schema_116
,Schema_117
,Schema_118
,Schema_119
,Schema_120
,Schema_121
,Schema_122
,Schema_123
,Schema_124
,Schema_125
,Schema_126
,Schema_127
,Schema_128
,Schema_129
,Schema_130
,Schema_131
,Schema_132
,Schema_133
,Schema_134
,Schema_135
,Schema_136
,Schema_137
,Schema_138
,Schema_139
,Schema_140
,Schema_141
,Schema_142
,Schema_143
,Schema_144
,Schema_145
,Schema_146
,Schema_147
,Schema_148
,Schema_149
,Schema_150
,Schema_151
,Schema_152
,Schema_153
,Schema_154
,Schema_155
,Schema_156
,Schema_157
,Schema_158
,Schema_159
,Schema_160
,Schema_161
,Schema_83
,Schema_84
,Schema_85
,Schema_86
,Schema_87
,Schema_88
,Schema_89
,Schema_90
,Schema_91
,Schema_92
,Schema_93
,Schema_94
,Schema_95
,Schema_96
,Schema_97
,Schema_98
,Schema_99
public abstract class SchemaVersion extends Object
A version of the database schema.
-
-
Field Summary
Fields Modifier and Type Field Description static Class<Schema_161>
C
The current schema version.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SchemaVersion(com.google.inject.Provider<? extends SchemaVersion> prior)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
check(UpdateUI ui, CurrentSchemaVersion curr, com.google.gwtorm.server.SchemaFactory<ReviewDb> schema)
protected static void
execute(ReviewDb db, String sql)
Execute an SQL statement.protected void
finish(CurrentSchemaVersion curr, ReviewDb db)
Mark the current schema version.static int
getBinaryVersion()
SchemaVersion
getPrior()
int
getVersionNbr()
static int
guessVersion(Class<?> c)
protected void
migrateData(ReviewDb db, UpdateUI ui)
Invoked between updateSchema (adds new columns/tables) and pruneSchema (removes deleted columns/tables).protected static com.google.gwtorm.jdbc.JdbcExecutor
newExecutor(ReviewDb db)
Open a new statement executor.protected static Statement
newStatement(ReviewDb db)
Open a new single statement.protected static PreparedStatement
prepareStatement(ReviewDb db, String sql)
Open a new prepared statement.protected void
preUpdateSchema(ReviewDb db)
Invoked before updateSchema adds new columns/tables.protected static void
renameColumn(ReviewDb db, String table, String from, String to)
Rename an existing column.protected static void
renameTable(ReviewDb db, String from, String to)
Rename an existing table.
-
-
-
Field Detail
-
C
public static final Class<Schema_161> C
The current schema version.
-
-
Constructor Detail
-
SchemaVersion
protected SchemaVersion(com.google.inject.Provider<? extends SchemaVersion> prior)
-
-
Method Detail
-
getBinaryVersion
public static int getBinaryVersion()
-
guessVersion
public static int guessVersion(Class<?> c)
-
getVersionNbr
public final int getVersionNbr()
- Returns:
- the
CurrentSchemaVersion.versionNbr
this step targets.
-
getPrior
public final SchemaVersion getPrior()
-
check
public final void check(UpdateUI ui, CurrentSchemaVersion curr, com.google.gwtorm.server.SchemaFactory<ReviewDb> schema) throws com.google.gwtorm.server.OrmException, SQLException
- Throws:
com.google.gwtorm.server.OrmException
SQLException
-
preUpdateSchema
protected void preUpdateSchema(ReviewDb db) throws com.google.gwtorm.server.OrmException, SQLException
Invoked before updateSchema adds new columns/tables.- Parameters:
db
- open database handle.- Throws:
com.google.gwtorm.server.OrmException
- if a Gerrit-specific exception occurred.SQLException
- if an underlying SQL exception occurred.
-
migrateData
protected void migrateData(ReviewDb db, UpdateUI ui) throws com.google.gwtorm.server.OrmException, SQLException
Invoked between updateSchema (adds new columns/tables) and pruneSchema (removes deleted columns/tables).- Parameters:
db
- open database handle.ui
- interface for interacting with the user.- Throws:
com.google.gwtorm.server.OrmException
- if a Gerrit-specific exception occurred.SQLException
- if an underlying SQL exception occurred.
-
finish
protected void finish(CurrentSchemaVersion curr, ReviewDb db) throws com.google.gwtorm.server.OrmException
Mark the current schema version.- Throws:
com.google.gwtorm.server.OrmException
-
renameTable
protected static void renameTable(ReviewDb db, String from, String to) throws com.google.gwtorm.server.OrmException
Rename an existing table.- Throws:
com.google.gwtorm.server.OrmException
-
renameColumn
protected static void renameColumn(ReviewDb db, String table, String from, String to) throws com.google.gwtorm.server.OrmException
Rename an existing column.- Throws:
com.google.gwtorm.server.OrmException
-
execute
protected static void execute(ReviewDb db, String sql) throws SQLException
Execute an SQL statement.- Throws:
SQLException
-
newStatement
protected static Statement newStatement(ReviewDb db) throws SQLException
Open a new single statement.- Throws:
SQLException
-
prepareStatement
protected static PreparedStatement prepareStatement(ReviewDb db, String sql) throws SQLException
Open a new prepared statement.- Throws:
SQLException
-
newExecutor
protected static com.google.gwtorm.jdbc.JdbcExecutor newExecutor(ReviewDb db) throws com.google.gwtorm.server.OrmException
Open a new statement executor.- Throws:
com.google.gwtorm.server.OrmException
-
-