Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

jumpn/ecto_cockroachdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated / No longer needed !

This fork is no longer necessary given CockroackDB 20.1+ supports timestamp with optional precision. You can now use the Postgresql Adaptor bundled with ecto_sql, the only special things you need to do is to disable migration locking in your repo config with: migration_lock: nil

CockroachDB Ecto Adaptor

This is a very small fork of the official Postgresql Adaptor bundled with ecto_sql.

The main reason for this fork is Ecto 3.x no longer keeps microseconds information for :time, :naive_datetime and :utc_datetime.

The net effect is it uses timestamp(0) when creating fields with such types and the migration table used by Ecto is using one of those types.

The problem is CockroachDB does not support timestamp with precision unless it's the default precision (6).

This adaptor use the default precision for those types. It also disable the migration lock given locking is not supported by CockroachDB either.

For more information, check the github issue

Installation

The package can be installed by adding ecto_cockroachdb to your list of dependencies in mix.exs:

def deps do
  [
    {:ecto_cockroachdb, "~> 1.0.0"}
  ]
end

Usage

# In your application code
defmodule Sample.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.CockroachDB
end