<commit_before>package com.raizlabs.android.dbflow.sql.migration;

import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;

import com.raizlabs.android.dbflow.sql.index.Index;
import com.raizlabs.android.dbflow.structure.Model;

/**
 * Description: Defines and enables an Index structurally through a migration.
 */
public class IndexMigration<ModelClass extends Model> extends BaseMigration {

    /**
     * The table to index on
     */
    private Class<ModelClass> mOnTable;

    /**
     * The name of this index
     */
    private String mName;

    /**
     * The underlying index object.
     */
    private Index<ModelClass> mIndex;

    public IndexMigration(@NonNull String name, @NonNull Class<ModelClass> mOnTable) {
        this.mOnTable = mOnTable;
        this.mName = name;
    }

    @Override
    public void onPreMigrate() {
        super.onPreMigrate();
        mIndex = getIndex();
    }

    @Override
    public void migrate(SQLiteDatabase database) {
        getIndex().enable();
    }

    @Override
    public void onPostMigrate() {
        mOnTable = null;
        mName = null;
        mIndex = null;
    }

    /**
     * Adds a column to the underlying INDEX
     *
     * @param columnName The name of the column to add to the Index
     * @return This migration
     */<commit_msg>fix for recursive call to database. fixes #139<commit_after>package com.raizlabs.android.dbflow.sql.migration;

import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;

import com.raizlabs.android.dbflow.sql.index.Index;
import com.raizlabs.android.dbflow.structure.Model;

/**
 * Description: Defines and enables an Index structurally through a migration.
 */
public class IndexMigration<ModelClass extends Model> extends BaseMigration {

    /**
     * The table to index on
     */
    private Class<ModelClass> mOnTable;

    /**
     * The name of this index
     */
    private String mName;

    /**
     * The underlying index object.
     */
    private Index<ModelClass> mIndex;

    public IndexMigration(@NonNull String name, @NonNull Class<ModelClass> mOnTable) {
        this.mOnTable = mOnTable;
        this.mName = name;
    }

    @Override
    public void onPreMigrate() {
        super.onPreMigrate();
        mIndex = getIndex();
    }

    @Override
    public void migrate(SQLiteDatabase database) {
        database.execSQL(getIndex().getQuery());
    }

    @Override
    public void onPostMigrate() {
        mOnTable = null;
        mName = null;
        mIndex = null;
    }

    /**
     * Adds a column to the underlying INDEX
     *
     * @param columnName The name of the column to add to the Index
     * @return This migration
     */
{'fraction_non_alphanumeric': 0.09480566654558663, 'fraction_numerical': 0.0010897203051216855, 'mean_word_length': 2.5766233766233766, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7324663', 'n_tokens_mistral': 820, 'n_tokens_neox': 811, 'n_words': 219}