<commit_before>package net.lshift.diffa.kernel.config

import org.hibernate.cfg.Configuration
import net.lshift.hibernate.migrations.MigrationBuilder
import java.sql.Types
import scala.collection.JavaConversions._

/**
 * This Step 'migrates' a schema/database to version 0 -
 * that is, it creates the base schema from scratch.
 */
object HibernateMigrationStep0000 extends HibernateMigrationStep {
  def versionId = 0
  def name = "Create schema"
  def createMigration(config: Configuration) = {
    val migration = new MigrationBuilder(config)

    migration.createTable("category_descriptor").
      column("category_id", Types.INTEGER, false).
      column("constraint_type", Types.VARCHAR, 20, false).
      column("prefix_length", Types.INTEGER, true).
      column("max_length", Types.INTEGER, true).
      column("step", Types.INTEGER, true).
      pk("category_id").
      withNativeIdentityGenerator()

    migration.createTable("config_options").
      column("domain", Types.VARCHAR, 255, false).
      column("opt_key", Types.VARCHAR, 255, false).
      column("opt_val", Types.VARCHAR, 255, true).
      pk("opt_key")

    migration.createTable("diffs").
      column("seq_id", Types.INTEGER, false).
      column("domain", Types.VARCHAR, 255, false).
      column("pair", Types.VARCHAR, 255, false).
      column("entity_id", Types.VARCHAR, 255, false).
      column("is_match", Types.BIT, false).
      column("detected_at", Types.TIMESTAMP, false).
      column("last_seen", Types.TIMESTAMP, false).
      column("upstream_vsn", Types.VARCHAR, 255, true).
      column("downstream_vsn", Types.VARCHAR, 255, true).
      column("ignored", Types.BIT, false).
      pk("seq_id").
      withNativeIdentityGenerator()

    migration.createTable("domains").
      column("name", Types.VARCHAR, 255, false).
      pk("name")

    migration.createTable("endpoint").
      column("domain", Types.VARCHAR, 255, false).
      column("name", Types.VARCHAR, 255, false).
      column("scan_url", Types.VARCHAR, 1024, true).
      column("content_retrieval_url", Types.VARCHAR, 1024, true).
      column("version_generation_url", Types.VARCHAR, 1024, true).
      column("inbound_url", Types.VARCHAR, 1024, true).
      column("content_type", Types.VARCHAR, 255, false).
      column("inbound_content_type", Types.VARCHAR, 255, true).
      pk("name", "domain")// TODO is this order ideal?

    migration.createTable("endpoint_categories").
      column("domain", Types.VARCHAR, 255, false).
      column("id", Types.VARCHAR, 255, false).
      column("category_descriptor_id", Types.INTEGER, false).
      column("name", Types.VARCHAR, 255, false).
      pk("id", "name")

    migration.createTable("endpoint_views").
      column("name", Types.VARCHAR, 255, false).
      column("endpoint", Types.VARCHAR, 255, false).
      column("domain", Types.VARCHAR, 50, false).
      pk("name", "endpoint", "domain")

    migration.createTable("endpoint_views_categories").
      column("name", Types.VARCHAR, 255, false).
      column("endpoint", Types.VARCHAR, 255, false).
      column("domain", Types.VARCHAR, 50, false).
      column("category_descriptor_id", Types.INTEGER, false).
      column("category_name", Types.VARCHAR, 255, false).
      pk("name", "endpoint", "domain", "category_name")
    
    migration.createTable("escalations").
      column("domain", Types.VARCHAR, 255, false).
      column("name", Types.VARCHAR, 255, false).
      column("pair_key", Types.VARCHAR, 255, false).
      column("action", Types.VARCHAR, 255, false).
      column("action_type", Types.VARCHAR, 255, false).
      column("event", Types.VARCHAR, 255, false).
      column("origin", Types.VARCHAR, 255, false).
      pk("name", "pair_key")

    migration.createTable("members").
      column("domain_name", Types.VARCHAR, 255, false).
      column("user_name", Types.VARCHAR, 255, false).
      pk("user_name", "domain_name")
    
    migration.createTable("pair").
      column("domain", Types.VARCHAR, 255, false).
      column("pair_key", Types.VARCHAR, 255, false).
      column("upstream", Types.VARCHAR, 255, false).
      column("downstream", Types.VARCHAR, 255, false).
      column("uep_domain", Types.VARCHAR, 255, false).
      column("dep_domain", Types.VARCHAR, 255, false).
      column("version_policy_name", Types.VARCHAR, 255, true).
      column("matching_timeout", Types.INTEGER, true).
      column("scan_cron_spec", Types.VARCHAR, 255, true).
      pk("pair_key", "domain")// TODO is this order ideal?<commit_msg>Collapsed versions 12 and 13<commit_after>package net.lshift.diffa.kernel.config

import org.hibernate.cfg.Configuration
import net.lshift.hibernate.migrations.MigrationBuilder
import java.sql.Types
import scala.collection.JavaConversions._

/**
 * This Step 'migrates' a schema/database to version 0 -
 * that is, it creates the base schema from scratch.
 */
object HibernateMigrationStep0000 extends HibernateMigrationStep {
  def versionId = 0
  def name = "Create schema"
  def createMigration(config: Configuration) = {
    val migration = new MigrationBuilder(config)

    migration.createTable("category_descriptor").
      column("category_id", Types.INTEGER, false).
      column("constraint_type", Types.VARCHAR, 20, false).
      column("prefix_length", Types.INTEGER, true).
      column("max_length", Types.INTEGER, true).
      column("step", Types.INTEGER, true).
      pk("category_id").
      withNativeIdentityGenerator()

    migration.createTable("config_options").
      column("domain", Types.VARCHAR, 255, false).
      column("opt_key", Types.VARCHAR, 255, false).
      column("opt_val", Types.VARCHAR, 255, true).
      pk("opt_key")

    migration.createTable("diffs").
      column("seq_id", Types.INTEGER, false).
      column("domain", Types.VARCHAR, 255, false).
      column("pair", Types.VARCHAR, 255, false).
      column("entity_id", Types.VARCHAR, 255, false).
      column("is_match", Types.BIT, false).
      column("detected_at", Types.TIMESTAMP, false).
      column("last_seen", Types.TIMESTAMP, false).
      column("upstream_vsn", Types.VARCHAR, 255, true).
      column("downstream_vsn", Types.VARCHAR, 255, true).
      column("ignored", Types.BIT, false).
      pk("seq_id").
      withNativeIdentityGenerator()

    migration.createTable("domains").
      column("name", Types.VARCHAR, 255, false).
      pk("name")

    migration.createTable("endpoint").
      column("domain", Types.VARCHAR, 255, false).
      column("name", Types.VARCHAR, 255, false).
      column("scan_url", Types.VARCHAR, 1024, true).
      column("content_retrieval_url", Types.VARCHAR, 1024, true).
      column("version_generation_url", Types.VARCHAR, 1024, true).
      column("inbound_url", Types.VARCHAR, 1024, true).
      column("content_type", Types.VARCHAR, 255, false).
      pk("name", "domain")// TODO is this order ideal?

    migration.createTable("endpoint_categories").
      column("domain", Types.VARCHAR, 255, false).
      column("id", Types.VARCHAR, 255, false).
      column("category_descriptor_id", Types.INTEGER, false).
      column("name", Types.VARCHAR, 255, false).
      pk("id", "name")

    migration.createTable("endpoint_views").
      column("name", Types.VARCHAR, 255, false).
      column("endpoint", Types.VARCHAR, 255, false).
      column("domain", Types.VARCHAR, 50, false).
      pk("name", "endpoint", "domain")

    migration.createTable("endpoint_views_categories").
      column("name", Types.VARCHAR, 255, false).
      column("endpoint", Types.VARCHAR, 255, false).
      column("domain", Types.VARCHAR, 50, false).
      column("category_descriptor_id", Types.INTEGER, false).
      column("category_name", Types.VARCHAR, 255, false).
      pk("name", "endpoint", "domain", "category_name")
    
    migration.createTable("escalations").
      column("domain", Types.VARCHAR, 255, false).
      column("name", Types.VARCHAR, 255, false).
      column("pair_key", Types.VARCHAR, 255, false).
      column("action", Types.VARCHAR, 255, false).
      column("action_type", Types.VARCHAR, 255, false).
      column("event", Types.VARCHAR, 255, false).
      column("origin", Types.VARCHAR, 255, false).
      pk("name", "pair_key")

    migration.createTable("members").
      column("domain_name", Types.VARCHAR, 255, false).
      column("user_name", Types.VARCHAR, 255, false).
      pk("user_name", "domain_name")
    
    migration.createTable("pair").
      column("domain", Types.VARCHAR, 255, false).
      column("pair_key", Types.VARCHAR, 255, false).
      column("upstream", Types.VARCHAR, 255, false).
      column("downstream", Types.VARCHAR, 255, false).
      column("uep_domain", Types.VARCHAR, 255, false).
      column("dep_domain", Types.VARCHAR, 255, false).
      column("version_policy_name", Types.VARCHAR, 255, true).
      column("matching_timeout", Types.INTEGER, true).
      column("scan_cron_spec", Types.VARCHAR, 255, true).
      column("allow_manual_scans", Types.BIT, 1, true, 0).
      pk("pair_key", "domain")// TODO is this order ideal?
{'fraction_non_alphanumeric': 0.1540242557883131, 'fraction_numerical': 0.031642778390297686, 'mean_word_length': 3.632788559754852, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5632507', 'n_tokens_mistral': 3011, 'n_tokens_neox': 2698, 'n_words': 614}