Skip to content

Commit

Permalink
Merge branch 'saschpe-deletetrigger' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
agrosner committed Dec 28, 2017
2 parents db2caad + 7ff338d commit e8330fc
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions dbflow/src/main/java/com/raizlabs/android/dbflow/sql/SqlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,32 @@ public static Uri getNotificationUri(@NonNull String contentAuthority,
/**
* Drops an active TRIGGER by specifying the onTable and triggerName
*
* @param mOnTable The table that this trigger runs on
* @param onTable The table that this trigger runs on
* @param triggerName The name of the trigger
*/
public static void dropTrigger(@NonNull Class<?> mOnTable, @NonNull String triggerName) {
public static void dropTrigger(Class<?> onTable, String triggerName) {
QueryBuilder queryBuilder = new QueryBuilder("DROP TRIGGER IF EXISTS ")
.append(triggerName);
FlowManager.getDatabaseForTable(mOnTable).getWritableDatabase().execSQL(queryBuilder.getQuery());
.append(triggerName);
FlowManager.getDatabaseForTable(onTable).getWritableDatabase().execSQL(queryBuilder.getQuery());
}

/**
* Drops an active INDEX by specifying the onTable and indexName
* Drops an active TRIGGER by specifying the databaseWrapper and triggerName
*
* @param indexName The name of the index.
* @param databaseWrapper The manually specified wrapper.
* @param triggerName The name of the trigger
*/
public static void dropTrigger(DatabaseWrapper databaseWrapper, String triggerName) {
QueryBuilder queryBuilder = new QueryBuilder("DROP TRIGGER IF EXISTS ")
.append(triggerName);
databaseWrapper.execSQL(queryBuilder.getQuery());
}

/**
* Drops an active INDEX by specifying the databaseWrapper and indexName
*
* @param databaseWrapper The manually specified wrapper.
* @param indexName The name of the index.
*/
public static void dropIndex(@NonNull DatabaseWrapper databaseWrapper,
@NonNull String indexName) {
Expand All @@ -179,8 +192,13 @@ public static void dropIndex(@NonNull DatabaseWrapper databaseWrapper,
databaseWrapper.execSQL(queryBuilder.getQuery());
}

public static void dropIndex(@NonNull Class<?> onTable,
@NonNull String indexName) {
/**
* Drops an active INDEX by specifying the onTable and indexName
*
* @param onTable The table that this trigger runs on
* @param indexName The name of the index.
*/
public static void dropIndex(Class<?> onTable, String indexName) {
dropIndex(FlowManager.getDatabaseForTable(onTable).getWritableDatabase(), indexName);
}

Expand Down

0 comments on commit e8330fc

Please sign in to comment.