Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void applySchema(DataBaseSchema new_schema, byte[] version)
- throws DBStorageException, DBSavepointException
- {
- if (new_schema == null)
- {
- throw new MigrationException("schema must be not null");
- }
- if (!hasValidDB())
- {
- throw new DBStorageException("db '" + name_ + "' is invalid");
- }
- if (!version_mgr_.requiresUpdate(version))
- {
- DBLog.info("schema for DB '" + name_ + "' is already newest");
- return;
- }
- else
- {
- try
- {
- beginTransaction();
- final DataBaseSchema curr_db_schema = SQLSchemaReader.readDBSchema(this);
- createAndChangeTables(curr_db_schema, new_schema);
- removeOldTables(curr_db_schema, new_schema);
- if (!setActiveTransactionSuccessful())
- {
- throw new DBStorageException("failed to set transaction as successful");
- }
- }
- catch (DBSchemaException ex)
- {
- throw new MigrationException("failed migration for db schema '" + new_schema.getName() + "'", ex);
- }
- finally
- {
- endTransaction();
- }
- version_mgr_.saveSchemaVersion(version);
- }
- curr_schema_ = new_schema;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement