20260812120000_create_atendimento_golden_labels_table.cjs 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. exports.up = function (knex) {
  2. return knex.schema.createTable("atendimento_golden_labels", (t) => {
  3. t.integer("AtendimentoId").unsigned().primary();
  4. t.string("Status", 12).notNullable().defaultTo("pendente"); // pendente | rotulado
  5. // espelha atendimento_avaliacoes, porém tudo nullable: NULL = ainda não rotulado
  6. t.tinyint("ScoreAtendente").unsigned().nullable(); // 1 a 10
  7. t.text("JustificativaScore").nullable();
  8. t.string("Resolvido", 12).nullable(); // sim | nao | parcial | indefinido
  9. t.string("Sentimento", 12).nullable(); // positivo | neutro | negativo | indefinido
  10. t.text("Resumo").nullable();
  11. t.text("Sugestoes").nullable(); // JSON array de strings
  12. t.text("Atendentes").nullable(); // JSON array de strings
  13. t.boolean("VisitaAgendada").nullable();
  14. t.string("HorarioVisitaInformado", 15).nullable(); // sim | nao | nao_se_aplica
  15. t.string("HorarioVisita", 150).nullable();
  16. t.string("StatusCancelamento", 12).nullable(); // nao | ameacou | cancelou | indefinido
  17. t.text("MotivoCancelamento").nullable();
  18. t.timestamp("SampledAt").notNullable().defaultTo(knex.fn.now()); // quando entrou na amostra do golden set
  19. t.timestamp("LabeledAt").nullable(); // quando terminou de ser rotulado
  20. t.timestamp("CreatedAt").notNullable().defaultTo(knex.fn.now());
  21. t.timestamp("UpdatedAt").notNullable().defaultTo(knex.fn.now());
  22. t.foreign("AtendimentoId").references("atendimentos.Id").onDelete("CASCADE");
  23. t.index(["Status"]);
  24. });
  25. };
  26. exports.down = function (knex) {
  27. return knex.schema.dropTable("atendimento_golden_labels");
  28. };