<commit_before># mig

Go SQL migration package

## Usage

```go
import "github.com/jagregory/mig"

mig.Define(`
	create table foo ( id integer );
`)

mig.DefineVersion(2, `
	create table bar ( id integer );
`)

mig.Migrate(db)
```

The `Define` and `DefineVersion` functions are used to define a migration
and the SQL that will be executed for it. The `Migrate` function actually
executes the migrations. An `error` will be returned from `Migrate` if
anything bad happens.<commit_msg>README - how it works<commit_after># mig

Go SQL migration package

## Usage

```go
import "github.com/jagregory/mig"

mig.Define(`
	create table foo ( id integer );
`)

mig.DefineVersion(2, `
	create table bar ( id integer );
`)

mig.Migrate(db)
```

The `Define` and `DefineVersion` functions are used to define a migration
and the SQL that will be executed for it. The `Migrate` function actually
executes the migrations. An `error` will be returned from `Migrate` if
anything bad happens.

## How it works

Mig will create a `db_version` table in your database with a `version int`
column. Each migration will be executed in the order they're defined in
unless there's a corresponding row in the `db_version` table. After each
successful migration a row will be inserted in `db_version` for that
migration.
{'fraction_non_alphanumeric': 0.08964451313755796, 'fraction_numerical': 0.0015455950540958269, 'mean_word_length': 4.4641350210970465, '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': '6451869', 'n_tokens_mistral': 413, 'n_tokens_neox': 396, 'n_words': 175}