Export current schema of ActiveRecord models as markdown or CSV
The schema list (schemate.md) looks like this:
# Table name: `users` ## Columns |FieldName |Attitutde |Size |NULL |Default |Comment | |---|---|---|---|---|---| |id |integer |8 |false | || |name |string |255 |true | || |email |string |255 |false | || |crypted_password |string |255 |true | || |salt |string |255 |true | ||
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install schemate
Export schema to CSV:
$ bundle exec rake schemate:export_csv
Export schema to Markdown:
$ bundle exec rake schemate:export_md
To generate a configuration file(config/initializers/schemate.rb), to set default options:
$ rails g schemate:install
Edit this file to control auto generation, and output format.
By default, schema is exported only when you run
If you want to export schema automatically with
rake db:migrate, edit the file and change:
config.auto_generate = true
By default, auto generate file type is markdown.
If you want to generate file as csv, edit the file and change:
config.auto_generate_type = 'csv'
Bug reports and pull requests are welcome on GitHub at https://github.com/palan-inc/schemate. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Schemate project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.