<commit_before>-- Add field for municipality ID in company table.
ALTER TABLE company
ADD CompanyMunicipalityID INT(11);

-- Populate this field with values from kommune table, based on current CompanyMunicipality number in company table.
UPDATE company AS c INNER JOIN kommune AS k
ON k.KommuneNumber = c.CompanyMunicipality
SET c.CompanyMunicipalityID = k.KommuneID;

-- Remove CompanyMunicipality and CompanyMunicipalityName from company table. These are replaced now with ID field.
ALTER TABLE company
DROP CompanyMunicipality,
DROP CompanyMunicipalityName;<commit_msg>Fix migration to retain the previous municipality<commit_after>-- Add field for municipality ID in company table.
ALTER TABLE company
ADD CompanyMunicipalityID INT(11);

-- Add municipality if not existing in the kommune table
REPLACE INTO kommune (KommuneNumber, KommuneName, Sone)
SELECT CompanyMunicipality, CompanyMunicipalityName, 1
FROM company
WHERE CompanyMunicipality IS NOT NULL OR CompanyMunicipalityName IS NOT NULL OR CompanyMunicipality != '' OR CompanyMunicipalityName != '';

-- Populate this field with values from kommune table, based on current CompanyMunicipality number in company table.
UPDATE company AS c INNER JOIN kommune AS k
ON k.KommuneNumber = c.CompanyMunicipality
SET c.CompanyMunicipalityID = k.KommuneID;

-- Remove CompanyMunicipality and CompanyMunicipalityName from company table. These are replaced now with ID field.
ALTER TABLE company
DROP CompanyMunicipality,
DROP CompanyMunicipalityName;
{'fraction_non_alphanumeric': 0.045877659574468085, 'fraction_numerical': 0.003324468085106383, 'mean_word_length': 5.7792792792792795, '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': '3021811', 'n_tokens_mistral': 412, 'n_tokens_neox': 404, 'n_words': 174}