<commit_before>module TemporalTables
  module TemporalAdapter
    def create_table(table_name, options = {}, &block)
      if options[:temporal_bypass]
        super table_name, options, &block
      else
        skip_table = TemporalTables.skipped_temporal_tables.include?(table_name.to_sym) || table_name.to_s =~ /_h$/

        super table_name, options do |t|
          block.call t

          if TemporalTables.add_updated_by_field && !skip_table
            t.column :updated_by, TemporalTables.updated_by_type
          end
        end

        if options[:temporal] || (TemporalTables.create_by_default && !skip_table)
          add_temporal_table table_name, options
        end
      end
    end

    def add_temporal_table(table_name, options = {})
      create_table temporal_name(table_name), options.merge(id: false, primary_key: "history_id", temporal_bypass: true) do |t|
        t.integer   :id
        t.datetime :eff_from, :null => false, limit: 6
        t.datetime :eff_to,   :null => false, limit: 6, :default => "9999-12-31"

        for c in columns(table_name)
          next if c.name == "id"
          t.send c.type, c.name, :limit => c.limit<commit_msg>fix for when the tables already have updated_by<commit_after>module TemporalTables
  module TemporalAdapter
    def create_table(table_name, options = {}, &block)
      if options[:temporal_bypass]
        super table_name, options, &block
      else
        skip_table = TemporalTables.skipped_temporal_tables.include?(table_name.to_sym) || table_name.to_s =~ /_h$/

        super table_name, options do |t|
          block.call t

          if TemporalTables.add_updated_by_field && !skip_table
            updated_by_already_exists = t.columns.any? { |c| c.name == "updated_by" }
            if updated_by_already_exists
              puts "consider adding #{table_name} to TemporalTables skip_table"
            else
              t.column :updated_by, TemporalTables.updated_by_type
            end
          end
        end

        if options[:temporal] || (TemporalTables.create_by_default && !skip_table)
          add_temporal_table table_name, options
        end
      end
    end

    def add_temporal_table(table_name, options = {})
      create_table temporal_name(table_name), options.merge(id: false, primary_key: "history_id", temporal_bypass: true) do |t|
        t.integer   :id
        t.datetime :eff_from, :null => false, limit: 6
        t.datetime :eff_to,   :null => false, limit: 6, :default => "9999-12-31"

        for c in columns(table_name)
          next if c.name == "id"
          t.send c.type, c.name, :limit => c.limit
{'fraction_non_alphanumeric': 0.09711684370257967, 'fraction_numerical': 0.007587253414264037, 'mean_word_length': 2.5780189959294435, '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': '6257086', 'n_tokens_mistral': 859, 'n_tokens_neox': 801, 'n_words': 194}