Postgrex.Extension and Ecto.Type for PostgreSQL isn module
Go to file
dependabot[bot] 586615667e
Bump postgrex from 0.17.2 to 0.17.3
Bumps [postgrex](https://github.com/elixir-ecto/postgrex) from 0.17.2 to 0.17.3.
- [Release notes](https://github.com/elixir-ecto/postgrex/releases)
- [Changelog](https://github.com/elixir-ecto/postgrex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/elixir-ecto/postgrex/compare/v0.17.2...v0.17.3)

---
updated-dependencies:
- dependency-name: postgrex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-30 01:36:10 +00:00
.github Make it possible to manually trigger CI workflow 2023-07-17 20:13:19 +02:00
config Migrate from Mix.Config to Config 2022-05-10 22:57:21 +02:00
lib Avoid compile-time warnings: 2023-07-14 14:35:14 +02:00
test Set up PostgreSQL with GitHub Actions 2022-05-10 23:41:51 +02:00
.formatter.exs Add .formatter.exs 2018-01-26 17:55:08 +01:00
.gitignore Ignore emacs *~ temp files 2016-01-10 12:46:28 +01:00
.tool-versions Bump local elixir and erlang versions 2023-07-17 20:10:53 +02:00
README.md Update documentation on config 2022-05-10 22:57:30 +02:00
mix.exs Bump dependencies 2023-07-17 20:03:16 +02:00
mix.lock Bump postgrex from 0.17.2 to 0.17.3 2023-08-30 01:36:10 +00:00

README.md

ISN

Build Status

ISN adds a Postgrex.Extension and Ecto.Type definitions for the datatypes defined in the isn PostgreSQL module.

Usage

Ecto migrations

defmodule MyApp.Repo.Migrations.CreateBook do
  use Ecto.Migration

  def change do
    create table(:books) do
      add :isbn, :isbn13
      # other fields
    end
  end
end

Ecto Models

defmodule MyApp.Book do
  use MyApp.Web, :model

  schema "books" do
    field :isbn, ISN.ISBN13, read_after_writes: true
    # other fields
  end
end

Installation

Add the package to your Mixfile

defp deps do
  [{:isn, "~> 2.0"}]
end

Add the isn extension to your database

mix do isn.gen.migration, ecto.migrate

Add a lib/postgrex_types.ex file with the following content:

Postgrex.Types.define(MyApp.PostgrexTypes, [ISN], [])

Add the following lines in config.exs:

config :my_app, MyApp.Repo,
  types: MyApp.PostgrexTypes

Defined types

ISN adds the following ecto and corresponding postgrex types:

Ecto.Type Postgrex type
ISN.ISBN :isbn
ISN.ISBN13 :isbn13
ISN.ISMN :ismn
ISN.ISMN13 :ismn13
ISN.ISSN :issn
ISN.ISSN13 :issn13
ISN.EAN13 :ean13
ISN.UPC :upc