package jp.agentec.abook.abv.bl.data.tables;

import java.util.ArrayList;
import java.util.List;

import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;

/**
 * Created by leej on 2019/03/18.
 */

public class RTaskWorkerGroup extends SQLiteTableScript {

    public RTaskWorkerGroup() {
        super();
    }

    @Override
    public List<String> getCreateScript(int version) {
        List<String> ddl = new ArrayList<String>();
        StringBuffer sql = new StringBuffer();

        sql.append(" CREATE TABLE r_task_worker_group ( ");
        sql.append("        task_report_level INTEGER default 0 ");
        sql.append("      , operation_id BIGINT NOT NULL ");
        sql.append("      , group_id INTEGER NOT NULL ");
        sql.append("      , PRIMARY KEY (task_report_level, operation_id, group_id)      ");
        sql.append("      , FOREIGN KEY (operation_id) REFERENCES t_operation (operation_id) ");
        sql.append("      , FOREIGN KEY (group_id) REFERENCES m_worker_group (group_id)");
        sql.append(" ) ");
        ddl.add(sql.toString());

        return ddl;
    }


    @Override
    public List<String> getUpgradeScript(int oldVersion, int newVersion) {
        return null;
    }

    @Override
    public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
        return null;
    }
}