<commit_before># ModelSchema
ModelSchema lets you annotate a [Sequel](https://github.com/jeremyevans/sequel/)
Model with its expected schema (columns and indexes). Instead of seeing
a Sequel Model file that looks like this:

```rb
class User < Sequel::Model(:users)
end
```

You'll see one that looks like this:

```rb
class User < Sequel::Model(:users)
  model_schema do
    primary_key :id

    String :email, :null => false
    String :password, :null => false

    TrueClass :is_admin, :default => false

    DateTime :created_at, :null => false
    DateTime :updated_at

    index :email
  end
end
```

Unlike other similar gems, ModelSchema provides *enforcement*; if the schema you
specify doesn't match the table schema, ModelSchema will raise an error and
tell you exactly what's wrong, like so:

```
ModelSchema::SchemaError: Table users does not match the expected schema.

Table users has extra columns:

  Integer :age

Table users is missing columns:

  TrueClass :is_admin, :default => false

Table users has mismatched indexes:

  actual:    index [:email], :unique => true
  expected:  index [:email]

You may disable schema checks by passing :disable => true to model_schema or by
setting the ENV variable DISABLE_MODEL_SCHEMA=1.
```

When developing on a team, local databases of team members can easily get out
of sync due to differing migrations. ModelSchema immediately lets you know if
the schema you expect differs from the actual schema. This ensures you identify
database inconsistencies before they cause problems. As a nice added benefit,
ModelSchema lets you see a list of columns for a model directly within the
class itself.

## Installation
Add `model_schema` to your Gemfile:

```rb<commit_msg>Add note about other ORMs in README.<commit_after># ModelSchema
ModelSchema lets you annotate a [Sequel](https://github.com/jeremyevans/sequel/)
Model with its expected schema (columns and indexes). Instead of seeing
a Sequel Model file that looks like this:

```rb
class User < Sequel::Model(:users)
end
```

You'll see one that looks like this:

```rb
class User < Sequel::Model(:users)
  model_schema do
    primary_key :id

    String :email, :null => false
    String :password, :null => false

    TrueClass :is_admin, :default => false

    DateTime :created_at, :null => false
    DateTime :updated_at

    index :email
  end
end
```

Unlike other similar gems, ModelSchema provides *enforcement*; if the schema you
specify doesn't match the table schema, ModelSchema will raise an error and
tell you exactly what's wrong, like so:

```
ModelSchema::SchemaError: Table users does not match the expected schema.

Table users has extra columns:

  Integer :age

Table users is missing columns:

  TrueClass :is_admin, :default => false

Table users has mismatched indexes:

  actual:    index [:email], :unique => true
  expected:  index [:email]

You may disable schema checks by passing :disable => true to model_schema or by
setting the ENV variable DISABLE_MODEL_SCHEMA=1.
```

When developing on a team, local databases of team members can easily get out
of sync due to differing migrations. ModelSchema immediately lets you know if
the schema you expect differs from the actual schema. This ensures you identify
database inconsistencies before they cause problems. As a nice added benefit,
ModelSchema lets you see a list of columns for a model directly within the
class itself.

## Support for ActiveRecord
Currently, ModelSchema only works with [Sequel](https://github.com/jeremyevans/sequel/).
If you'd like something similar for other Ruby ORMs, like ActiveRecord, please
express your interest in [this issue](https://github.com/karthikv/model_schema/issues/1).

## Installation
Add `model_schema` to your Gemfile:

```rb
{'fraction_non_alphanumeric': 0.07598299681190224, 'fraction_numerical': 0.0007970244420828905, 'mean_word_length': 4.488338192419825, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 4, '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': '1388182', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1007, 'n_words': 488}