<commit_before>import config from 'src/config'
import Promise from 'bluebird'

const createOptions = config.server.rethinkdb.tableCreation

export async function up(r, connection) {
  const moderators = await r.table('moderators').run(connection)

  await Promise.each(moderators, async moderator => {
    const memberFound = await r.table('members')
      .get(moderator.id)
      .default(false)
      .run(connection)

    if (!memberFound) {
      return r.table('members').insert(moderator).run(connection)
    }
  })

  await r.tableDrop('moderators').run(connection)
}

export async function down(r, connection) {
  await r.tableCreate('moderators', createOptions).run(connection)
  await r.table('moderators').indexCreate('chapterId').run(connection)
}<commit_msg>omit unnecessary migration down fn<commit_after>import Promise from 'bluebird'

export async function up(r, connection) {
  const moderators = await r.table('moderators').run(connection)

  await Promise.each(moderators, async moderator => {
    const memberFound = await r.table('members')
      .get(moderator.id)
      .default(false)
      .run(connection)

    if (!memberFound) {
      return r.table('members').insert(moderator).run(connection)
    }
  })

  await r.tableDrop('moderators').run(connection)
}

export async function down() {
  // irreversible; data from dropped table not recoverable
}
{'fraction_non_alphanumeric': 0.12681159420289856, 'fraction_numerical': 0.0, 'mean_word_length': 4.373540856031128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7247656', 'n_tokens_mistral': 418, 'n_tokens_neox': 410, 'n_words': 92}