exports.up = function (knex) { return knex.schema.createTable("atendimento_avaliacoes", (t) => { t.integer("AtendimentoId").unsigned().primary(); t.boolean("Avaliavel").notNullable().defaultTo(true); // false = conversa sem conteúdo suficiente para avaliar t.tinyint("ScoreAtendente").unsigned().nullable(); // 1 a 10 t.text("JustificativaScore").nullable(); t.string("Resolvido", 12).notNullable().defaultTo("indefinido"); // sim | nao | parcial | indefinido t.string("Sentimento", 12).notNullable().defaultTo("indefinido"); // positivo | neutro | negativo | indefinido t.text("Resumo").nullable(); t.text("Sugestoes").nullable(); // JSON array de strings t.text("Atendentes").nullable(); // JSON array com nomes dos atendentes identificados t.boolean("VisitaAgendada").nullable(); t.string("HorarioVisitaInformado", 15).nullable(); // sim | nao | nao_se_aplica t.string("HorarioVisita", 150).nullable(); t.string("Modelo", 100).nullable(); t.bigInteger("UltimaMensagemId").unsigned().nullable(); // última mensagem considerada; avaliação fica pendente de novo se chegarem mensagens mais novas t.integer("TotalMensagens").unsigned().nullable(); t.timestamp("CreatedAt").notNullable().defaultTo(knex.fn.now()); t.timestamp("UpdatedAt").notNullable().defaultTo(knex.fn.now()); t.foreign("AtendimentoId").references("atendimentos.Id").onDelete("CASCADE"); t.index(["ScoreAtendente"]); t.index(["Resolvido"]); t.index(["Sentimento"]); }); }; exports.down = function (knex) { return knex.schema.dropTable("atendimento_avaliacoes"); };