<commit_before>Migrating the database between SimpleUser major versions
========================================================

## Migrating from SimpleUser 1.x to 2.x

In SimpleUser 1.x, newly added features were stored as custom fields instead of adding columns to the the users table,
to avoid breaking backward compatibility.

In version 2.0, those custom fields were moved into new columns in the users table.
The custom fields moved were: username, su:isEnabled, su:confirmationToken, and su:timePasswordResetRequested.

Changes made in version 2.0:
- Add columns to the users table: username, isEnabled, confirmationToken, timePasswordResetRequested
- Move data for those columns from custom fields to the users table, and delete those custom field rows.
- Make the users.time_created column unsigned (to avoid the "year 2038 problem")

A migration class is available to help migrate the database from version 1.x to 2.x,
and to revert from 2.x back to 1.x: [SimpleUser\Migration\MigrateV1ToV2](../src/SimpleUser/Migration/MigrateV1ToV2.php).

The migration class supports altering the schema for two database platforms: mysql and sqlite.
For other platforms, you can add the columns manually and then just migrate the data (see below).
(Pull requests would be appreciated to add DDL statements for other platforms.)

To run the migration, make a small script that exercises the migration class.
You can just run the migration all at once,
you can print the SQL commands so that you can examine them and then run them yourself,
or you can make the database changes manually and just migrate the data.

Before migrating, make sure to back up your existing database. Ex. for mysql:

    mysqldump -uroot -p --opt MYDB users user_custom_fields > users.sql

Running the migration:<commit_msg>Update MIGRATION.md<commit_after>Migrating the database between SimpleUser major versions
========================================================

## Migrating from SimpleUser 1.x to 2.x

In SimpleUser 1.x, newly added features were stored as custom fields instead of adding columns to the the users table,
to avoid breaking backward compatibility.

In version 2.0, those custom fields were moved into new columns in the users table.
The custom fields moved were: username, su:isEnabled, su:confirmationToken, and su:timePasswordResetRequested.

Changes made in version 2.0:
- Add columns to the users table: username, isEnabled, confirmationToken, timePasswordResetRequested
- Move data for those columns from custom fields to the users table, and delete those custom field rows.
- Make the users.time_created column unsigned (to avoid the "year 2038 problem")

A migration class is available to help migrate the database from version 1.x to 2.x,
and to revert from 2.x back to 1.x: [SimpleUser\Migration\MigrateV1ToV2](../src/SimpleUser/Migration/MigrateV1ToV2.php).

The migration class supports altering the schema for two database platforms: mysql and sqlite.
For other platforms, you can add the columns manually and then just migrate the data (see below).
(Pull requests would be appreciated to add DDL statements for other platforms.)

To run the migration, make a small script that exercises the migration class.
You can just run the migration all at once,
you can print the SQL commands so that you can examine them and then run them yourself,
or you can make the database changes manually and just migrate the data.

Before migrating, make sure to back up your existing database. Ex. for mysql:

    DBNAME=mydb
    mysqldump -uroot -p --opt $DBNAME users user_custom_fields > simpleuser-v1-bak.sql

Running the migration:
{'fraction_non_alphanumeric': 0.07793996144312862, 'fraction_numerical': 0.010740842743045993, 'mean_word_length': 4.801916932907348, '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': '868203', 'n_tokens_mistral': 932, 'n_tokens_neox': 891, 'n_words': 501}