<commit_before>(ns migrations.026-fix-entry-ids
  (:require [clojure.java.jdbc :as j]
            [config.migrate-config :as config]
            [config.mdb-migrate-helper :as h]))

(defn up
  "Migrates the database up to version 26."
  []
  (println "migrations.026-fix-entry-ids up...")
  (doseq [t (h/get-collection-tablenames)]
    (println (str "Table: " t))

    ;; Set version id to a default value. Only DIF9 should have had null
    (h/sql (format "update %s set version_id = 'Not provided' where version_id is null and format = 'DIF'" t))

    ;; Version id does not allow null values anymore
    (h/sql (format "alter table %s modify (VERSION_ID not null)" t))

    (h/sql (format "update %s set entry_id = short_name where version_id = 'Not provided'" t))
    (h/sql (format "update %s set entry_id = short_name || '_V:' || version_id where version_id != 'Not provided'" t))))


(defn down
  "Migrates the database down from version 26."
  []
  (println "migrations.026-fix-entry-ids down...")
  (doseq [t (h/get-collection-tablenames)]
    (h/sql (format "alter table %s modify (VERSION_ID null)" t))
    (h/sql (format "update %s set entry_id = short_name where version_id = 'Not provided'" t))
    (h/sql (format "update %s set entry_id = short_name || '_' || version_id where version_id != 'Not provided'" t))))<commit_msg>CMR-2240: Removing down migration.<commit_after>(ns migrations.026-fix-entry-ids
  (:require [clojure.java.jdbc :as j]
            [config.migrate-config :as config]
            [config.mdb-migrate-helper :as h]))

(defn up
  "Migrates the database up to version 26."
  []
  (println "migrations.026-fix-entry-ids up...")
  (doseq [t (h/get-collection-tablenames)]
    (println (str "Table: " t))

    ;; Set version id to a default value. Only DIF9 should have had null
    (h/sql (format "update %s set version_id = 'Not provided' where version_id is null and format = 'DIF'" t))

    ;; Version id does not allow null values anymore
    (h/sql (format "alter table %s modify (VERSION_ID not null)" t))

    (h/sql (format "update %s set entry_id = short_name where version_id = 'Not provided'" t))
    (h/sql (format "update %s set entry_id = short_name || '_V:' || version_id where version_id != 'Not provided'" t))))


(defn down
  "Migrates the database down from version 26."
  []
  (println "migrations.026-fix-entry-ids down...")
  (throw (Exception. "This migration does not support 'down'")))
{'fraction_non_alphanumeric': 0.14086814086814087, 'fraction_numerical': 0.013104013104013105, 'mean_word_length': 3.4018018018018017, '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': '1687141', 'n_tokens_mistral': 842, 'n_tokens_neox': 812, 'n_words': 279}