<commit_before>exports.up = async function(knex, Promise) {
  await knex.schema.createTableIfNotExists('threads', table => {
    table.string('id', 36).notNullable().primary();
    table.integer('status').unsigned().notNullable().index();
    table.integer('is_legacy').unsigned().notNullable();
    table.string('user_id', 20).notNullable().index();
    table.string('user_name', 128).notNullable();
    table.string('channel_id', 20).nullable().unique();
    table.dateTime('created_at').notNullable().index();
  });

  await knex.schema.createTableIfNotExists('thread_messages', table => {
    table.increments('id');
    table.string('thread_id', 36).notNullable().index().references('id').inTable('threads').onDelete('CASCADE');
    table.integer('message_type').unsigned().notNullable();
    table.string('user_id', 20).nullable();
    table.string('user_name', 128).notNullable();
    table.mediumtext('body').notNullable();
    table.integer('is_anonymous').unsigned().notNullable();
    table.string('dm_message_id', 20).nullable().unique();
    table.dateTime('created_at').notNullable().index();
  });

  await knex.schema.createTableIfNotExists('blocked_users', table => {
    table.string('user_id', 20).primary().notNullable();
    table.string('user_name', 128).notNullable();
    table.string('blocked_by', 20).nullable();
    table.dateTime('blocked_at').notNullable();
  });

  await knex.schema.createTableIfNotExists('snippets', table => {
    table.string('trigger', 32).primary().notNullable();
    table.text('body').notNullable();
    table.integer('is_anonymous').unsigned().notNullable();
    table.string('created_by', 20).nullable();
    table.dateTime('created_at').notNullable();
  });
};

exports.down = async function(knex, Promise) {
  await knex.schema.dropTableIfExists('thread_messages');
  await knex.schema.dropTableIfExists('threads');
  await knex.schema.dropTableIfExists('blocked_users');
  await knex.schema.dropTableIfExists('snippets');
};<commit_msg>Fix migrations so they don't show Knex warnings<commit_after>exports.up = async function(knex, Promise) {
  if (! await knex.schema.hasTable("threads")) {
    await knex.schema.createTable("threads", table => {
      table.string("id", 36).notNullable().primary();
      table.integer("status").unsigned().notNullable().index();
      table.integer("is_legacy").unsigned().notNullable();
      table.string("user_id", 20).notNullable().index();
      table.string("user_name", 128).notNullable();
      table.string("channel_id", 20).nullable().unique();
      table.dateTime("created_at").notNullable().index();
    });
  }

  if (! await knex.schema.hasTable("thread_messages")) {
    await knex.schema.createTable("thread_messages", table => {
      table.increments("id");
      table.string("thread_id", 36).notNullable().index().references("id").inTable("threads").onDelete("CASCADE");
      table.integer("message_type").unsigned().notNullable();
      table.string("user_id", 20).nullable();
      table.string("user_name", 128).notNullable();
      table.mediumtext("body").notNullable();
      table.integer("is_anonymous").unsigned().notNullable();
      table.string("dm_message_id", 20).nullable().unique();
      table.dateTime("created_at").notNullable().index();
    });
  }

  if (! await knex.schema.hasTable("blocked_users")) {
    await knex.schema.createTable("blocked_users", table => {
      table.string("user_id", 20).primary().notNullable();
      table.string("user_name", 128).notNullable();
      table.string("blocked_by", 20).nullable();
      table.dateTime("blocked_at").notNullable();
    });
  }

  if (! await knex.schema.hasTable("snippets")) {
    await knex.schema.createTable("snippets", table => {
      table.string("trigger", 32).primary().notNullable();
      table.text("body").notNullable();
      table.integer("is_anonymous").unsigned().notNullable();
      table.string("created_by", 20).nullable();
      table.dateTime("created_at").notNullable();
    });
  }
};

exports.down = async function(knex, Promise) {
  if (await knex.schema.hasTable("thread_messages")) {
    await knex.schema.dropTable("thread_messages");
  }

  if (await knex.schema.hasTable("threads")) {
    await knex.schema.dropTable("threads");
  }

  if (await knex.schema.hasTable("blocked_users")) {
    await knex.schema.dropTable("blocked_users");
  }

  if (await knex.schema.hasTable("snippets")) {
    await knex.schema.dropTable("snippets");
  }
};
{'fraction_non_alphanumeric': 0.1933825173261793, 'fraction_numerical': 0.01296668902302705, 'mean_word_length': 4.8179453836150845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '665601', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1366, 'n_words': 163}