Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
master
Andrew DeMaria 8 years ago
parent 9540167d49
commit a097644e5f
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 77
      libresonic-main/src/main/java/org/libresonic/player/spring/DbmsVersionPrecondition.java
  2. 1
      libresonic-main/src/main/java/org/libresonic/player/spring/SpringLiquibase.java
  3. 2
      libresonic-main/src/main/resources/liquibase/legacy/schema32.xml
  4. 23
      libresonic-main/src/main/resources/liquibase/legacy/schema47.xml
  5. 21
      libresonic-main/src/main/resources/liquibase/legacy/schema53.xml

@ -0,0 +1,77 @@
package org.libresonic.player.spring;
import liquibase.changelog.ChangeSet;
import liquibase.changelog.DatabaseChangeLog;
import liquibase.database.Database;
import liquibase.exception.PreconditionErrorException;
import liquibase.exception.PreconditionFailedException;
import liquibase.exception.ValidationErrors;
import liquibase.exception.Warnings;
import liquibase.precondition.Precondition;
import liquibase.serializer.AbstractLiquibaseSerializable;
public class DbmsVersionPrecondition extends AbstractLiquibaseSerializable implements Precondition {
private Integer major;
private Integer minor;
@Override
public String getName() {
return "dbmsVersion";
}
@Override
public Warnings warn(Database database) {
return new Warnings();
}
@Override
public ValidationErrors validate(Database database) {
return new ValidationErrors();
}
@Override
public void check(
Database database, DatabaseChangeLog changeLog, ChangeSet changeSet
) throws PreconditionFailedException, PreconditionErrorException {
try {
int dbMajor = database.getDatabaseMajorVersion();
int dbMinor = database.getDatabaseMinorVersion();
if(major != null && !major.equals(dbMajor)) {
throw new PreconditionFailedException("DBMS Major Version Precondition failed: expected " + major + ", got " + dbMajor, changeLog, this);
}
if(minor != null && !minor.equals(dbMinor)) {
throw new PreconditionFailedException("DBMS Minor Version Precondition failed: expected " + minor + ", got " + dbMinor, changeLog, this);
}
} catch (PreconditionFailedException e) {
throw e;
} catch (Exception e) {
throw new PreconditionErrorException(e, changeLog, this);
}
}
@Override
public String getSerializedObjectName() {
return getName();
}
@Override
public String getSerializedObjectNamespace() {
return GENERIC_CHANGELOG_EXTENSION_NAMESPACE;
}
public Integer getMajor() {
return major;
}
public void setMajor(Integer major) {
this.major = major;
}
public Integer getMinor() {
return minor;
}
public void setMinor(Integer minor) {
this.minor = minor;
}
}

@ -51,6 +51,7 @@ public class SpringLiquibase extends liquibase.integration.spring.SpringLiquibas
if (StringUtils.trimToNull(this.defaultSchema) != null) {
database.setDefaultSchemaName(this.defaultSchema);
}
liquibase.precondition.PreconditionFactory.getInstance().register(DbmsVersionPrecondition.class);
return database;
}

@ -64,7 +64,7 @@
</rollback>
</changeSet>
<changeSet id="schema32_005" author="muff1nman">
<validCheckSum>7:d968449010bf1de51dac5f300359b2c5 </validCheckSum>
<validCheckSum>7:0d4fbe2adcca829c14d12a5b1a8229c5</validCheckSum>
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="podcast_episode"/>

@ -153,7 +153,7 @@
</rollback>
</changeSet>
<changeSet id="schema47_004" author="muff1nman">
<validCheckSum>7:c69a9ccadcb83d57684bb3b7aa34fb22</validCheckSum>
<validCheckSum>7:a3a788d87fd58508ecb4acac39e255c6</validCheckSum>
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="album" />
@ -216,6 +216,12 @@
</changeSet>
<changeSet id="schema47_005" author="muff1nman">
<preConditions onFail="MARK_RAN">
<not>
<dbms type="hsqldb" />
<customPrecondition className="org.libresonic.player.spring.DbmsVersionPrecondition" >
<param name="major" value="1" />
</customPrecondition>
</not>
<not>
<indexExists indexName="idx_album_name" />
</not>
@ -224,6 +230,21 @@
<column name="name"/>
</createIndex>
</changeSet>
<changeSet id="schema47_005_2" author="muff1nman">
<preConditions onFail="MARK_RAN">
<dbms type="hsqldb" />
<customPrecondition className="org.libresonic.player.spring.DbmsVersionPrecondition" >
<param name="major" value="1" />
</customPrecondition>
<sqlCheck expectedResult="0">
select count(*) from INFORMATION_SCHEMA.SYSTEM_INDEXINFO where
TABLE_NAME = 'album' and INDEX_NAME = 'idx_album_name';
</sqlCheck>
</preConditions>
<createIndex tableName="album" indexName="idx_album_name">
<column name="name"/>
</createIndex>
</changeSet>
<changeSet id="schema47_006" author="muff1nman">
<preConditions onFail="MARK_RAN">
<not>

@ -17,6 +17,12 @@
</changeSet>
<changeSet id="schema53_002" author="muff1nman">
<preConditions onFail="MARK_RAN">
<not>
<dbms type="hsqldb" />
<customPrecondition className="org.libresonic.player.spring.DbmsVersionPrecondition" >
<param name="major" value="1" />
</customPrecondition>
</not>
<not>
<indexExists indexName="idx_podcast_episode_url" />
</not>
@ -25,6 +31,21 @@
<column name="url"/>
</createIndex>
</changeSet>
<changeSet id="schema53_002_1" author="muff1nman">
<preConditions onFail="MARK_RAN">
<dbms type="hsqldb" />
<customPrecondition className="org.libresonic.player.spring.DbmsVersionPrecondition" >
<param name="major" value="1" />
</customPrecondition>
<sqlCheck expectedResult="0">
select count(*) from INFORMATION_SCHEMA.SYSTEM_INDEXINFO where
TABLE_NAME = 'podcast_episode' and INDEX_NAME = 'idx_podcast_episode_url';
</sqlCheck>
</preConditions>
<createIndex tableName="podcast_episode" indexName="idx_podcast_episode_url">
<column name="url"/>
</createIndex>
</changeSet>
<changeSet id="schema53_003" author="muff1nman">
<preConditions onFail="MARK_RAN">
<not>

Loading…
Cancel
Save