package cn.reghao.tnb.sb.db.autobatis.table.ddl;

import cn.reghao.tnb.sb.db.autobatis.table.SqlGenerator;
import cn.reghao.tnb.sb.db.autobatis.table.Table;

/**
 * DDL SQL 语句
 *
 * @author reghao
 * @date 2020-04-03 01:19:45
 */
public class DdlProvider {
    private final SqlGenerator sqlGenerator = new SqlGenerator();

    public String createDatabase(String db) {
        String charset = "utf8mb4";
        String collate = "utf8mb4_general_ci";
        return String.format("create database if not exists %s default charset %s collate %s", db, charset, collate);
    }

    public String copyTableSql(String srcTable, String destTable) {
        return String.format("create table %s like %s", destTable, srcTable);
    }

    public String createSql(Table table) {
        return sqlGenerator.createSql(table);
    }

    public String truncateSql(String table) {
        return sqlGenerator.truncateSql(table);
    }

    public String dropSql(String table) {
        return sqlGenerator.dropSql(table);
    }
}
