GitHub

A PostgreSQL (10) schema for storing microformats2 objects (as the canonical JSON representation), featuring:

  • Fast storage and querying (jsonb + GIN)
  • Uniqueness constraint on the first url value
  • Full text search
  • Automatic insert/update/delete notifications
  • Denormalization (embed linked objects like replies for exporting into JSON files or rendering to HTML templates)
  • Normalization (un-embed linked objects when importing from JSON files)
  • And more

Setup

  • Create a database e.g. sudo -u postgres createdb mywebsite
  • Run SELECT current_setting('default_text_search_config'); to check if your default language for full text search matches your website's (if not, change that setting)
  • Run the migrations using migrate e.g. migrate -path=migrations -url=postgres://localhost/mywebsite\?sslmode=disable up (or just run the migrations/*.up.sql files with psql if you don't want to bother with migrate) (so far there's only one migration)
  • Install the functions by running psql on functions/*.sql
  • Import JSON files using import.rb if you want

Development

Grab pgTAP (including pg_prove) to run the tests!

Contributing

Please feel free to submit pull requests!

By participating in this project you agree to follow the Contributor Code of Conduct.

The list of contributors is available on GitHub.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.

Read the original on github.com ↗