<commit_before>package de.avalax.fitbuddy.port.adapter.persistence;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class FitbuddySQLiteOpenHelper extends SQLiteOpenHelper {
    private Context context;
    private int createRessourceId;

    public FitbuddySQLiteOpenHelper(String name,int version, Context context, int createRessourceId) {
        super(context, name, null, version);
        this.context = context;
        this.createRessourceId = createRessourceId;
    }

    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
        if (!db.isReadOnly()) {
            // Enable foreign key constraints
            db.execSQL("PRAGMA foreign_keys=ON;");
        }
    }
    
    @Override
    public void onCreate(SQLiteDatabase database) {
        Log.d(getDatabaseName(), "Create new database");
        insertFromFile(database, context, createRessourceId);
    }

    @Override
    public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        Log.d(getDatabaseName(), "Upgrade from v" + oldVersion + " to v" + newVersion);
    }

    private void insertFromFile(SQLiteDatabase database, Context context, int resourceId) {
        try {
            InputStream insertsStream = context.getResources().openRawResource(resourceId);
            BufferedReader insertReader = new BufferedReader(new InputStreamReader(insertsStream));
            while (insertReader.ready()) {
                String insertStmt = insertReader.readLine();
                database.execSQL(insertStmt);
            }
            insertReader.close();
        } catch (IOException e) {
            Log.e(getDatabaseName(), e.getMessage(), e);
        }
    }
}<commit_msg>#9 enabled foreign key contraints<commit_after>package de.avalax.fitbuddy.port.adapter.persistence;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class FitbuddySQLiteOpenHelper extends SQLiteOpenHelper {
    private Context context;
    private int createRessourceId;

    public FitbuddySQLiteOpenHelper(String name, int version, Context context, int createRessourceId) {
        super(context, name, null, version);
        this.context = context;
        this.createRessourceId = createRessourceId;
    }

    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
        if (!db.isReadOnly()) {
            // Enable foreign key constraints
            db.execSQL("PRAGMA foreign_keys=ON;");
        }
    }

    @Override
    public void onCreate(SQLiteDatabase database) {
        Log.d(getDatabaseName(), "Create new database");
        insertFromFile(database, context, createRessourceId);
    }

    @Override
    public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        Log.d(getDatabaseName(), "Upgrade from v" + oldVersion + " to v" + newVersion);
    }

    private void insertFromFile(SQLiteDatabase database, Context context, int resourceId) {
        try {
            InputStream insertsStream = context.getResources().openRawResource(resourceId);
            BufferedReader insertReader = new BufferedReader(new InputStreamReader(insertsStream));
            while (insertReader.ready()) {
                String insertStmt = insertReader.readLine();
                database.execSQL(insertStmt);
            }
            insertReader.close();
        } catch (IOException e) {
            Log.e(getDatabaseName(), e.getMessage(), e);
        }
    }
}
{'fraction_non_alphanumeric': 0.09318355884605566, 'fraction_numerical': 0.0002552974214960429, 'mean_word_length': 3.0475206611570247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4445858', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1051, 'n_words': 241}