rivet-autoimporter alternatives and similar packages
Based on the "Database" category.
Alternatively, view rivet-autoimporter alternatives based on common mentions on social networks and blogs.
-
erd
Translates a plain text description of a relational database schema to a graphical entity-relationship diagram. -
persistent-redis
Persistence interface for Haskell allowing multiple storage methods. -
acid-state
Add ACID guarantees to any serializable Haskell data structure -
squeal-postgresql
Squeal, a deep embedding of SQL in Haskell -
postgresql-simple
Mid-level client library for accessing PostgreSQL from Haskell -
esqueleto
Bare bones, type-safe EDSL for SQL queries on persistent backends. -
HDBC-session
This repository includes a joined query generator based on typefull relational algebra, and mapping tools between SQL values list and Haskell record type. -
groundhog
This library maps datatypes to a relational model, in a way similar to what ORM libraries do in OOP. See the tutorial https://www.schoolofhaskell.com/user/lykahb/groundhog for introduction -
hw-kafka-client
Kafka client for Haskell, including auto-rebalancing consumers -
mysql-simple
A mid-level client library for the MySQL database, intended to be fast and easy to use. -
postgresql-simple-migration
PostgreSQL Schema Migrations for Haskell -
vcache
large, persistent, memcached values and structure sharing for Haskell -
direct-sqlite
Low-level binding to SQLite3. Includes UTF8 and BLOB support. -
haskelldb
A library for building re-usable and composable SQL queries. -
vcache-trie
large, persistent, memcached values and structure sharing for Haskell -
dbmigrations
A library for the creation, management, and installation of schema updates for relational databases. -
haskey
Transactional key-value store written entirely in Haskell -
postgresql-tx
[Moved to: https://github.com/Simspace/postgresql-tx] -
postgresql-typed
Haskell PostgreSQL library with compile-time type inference -
ampersand
Build database applications faster than anyone else, and keep your data pollution free as a bonus. -
postgresql-orm
An Haskell ORM (Object Relational Mapping) and migrations DSL for PostgreSQL. -
persistent-database-url
Parse DATABASE_URL into configuration types for Persistent
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of rivet-autoimporter or a related project?
README
Rivet - a database migration library for Haskell.
How it works
You write SQL or haskell DSL database migrations, and they are
compiled into a migrate
binary that knows how to run migrations,
roll them back, and inspect the state of the database. Since it is a
binary, it can be shipped around via whatever deployment mechanism you
use, and will be available in your production environment (where it
can talk to production databases), if you need that.
Usage
All migrations will be Haskell source files in a migrations
directory. They will be run in lexicographic order, which means you should
name them accordingly. The convention I've used in M2016..._description_of_change
,
where the beginning is a full timestamp. You should create the migrations
directory,
and then add a target to your cabal file.
Executable migrate
hs-source-dirs: src migrations
main-is: rivet.hs
Build-depends: base,
... -- same as your application
default-language: Haskell2010
An example migration might be:
{-# LANGUAGE OverloadedStrings #-}
module M20141211212630_add_type_to_gift_subscriptions where
import Control.Monad
import Database.Rivet.V0
migrate :: Migration IO ()
migrate = do addColumn "gift_subscriptions" (ColumnSpec "type" "text" Nothing (Just "not null"))
addColumn "gift_subscriptions" (ColumnSpec "country_code" "text" Nothing (Just "not null"))
Or
{-# LANGUAGE OverloadedStrings #-}
module M20160521_add_to_addr_index where
import Control.Monad
import Database.Rivet.V0
migrate :: Migration IO ()
migrate = sql up down
up = "CREATE INDEX CONCURRENTLY email_archive_to_addr_idx ON email_archive (to_addr);"
down = "DROP INDEX email_archive_to_addr_idx;"
See the full (at this point very limited) API in Database.Rivet.V0
.
Then you should create migrations/rivet.hs
. Currently, there is
still some copying / pasting, in particular, to figure out how to
connect to the database. The following will work, first loading
environment variables from a .env
file if it exists, and then
looking for an env.cfg
file in the configurator
format where it
will find database connection info. You can change this to be however
your application manages database connections. The preprocessor line
(second in file) and the last two lines in the main
function are
required; everything else could vary.
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -F -pgmF rivet-autoimporter #-}
module Main where
import qualified Configuration.Dotenv
import Control.Monad (when)
import qualified Data.Configurator as C
import Data.Monoid
import Database.Rivet.Adaptor.PostgreSQL
import qualified Database.Rivet.Main as Rivet
import System.Directory (doesFileExist)
import System.Environment
main :: IO ()
main = do e <- doesFileExist ".env"
when e $ Configuration.Dotenv.loadFile False ".env"
args <- getArgs
let (env, mode) =
case args of
[env', "up"] -> (env', Rivet.MigrateUp)
[env', "down"] -> (env', Rivet.MigrateDown)
[env', "status"] -> (env', Rivet.MigrateStatus)
_ -> error "Usage: [executable] [devel|prod|...] [up|down|status]"
conf <- C.load [C.Required (env <> ".cfg")]
host <- C.require conf "postgresql-simple.host"
port <- C.require conf "postgresql-simple.port"
user <- C.require conf "postgresql-simple.user"
pass <- C.require conf "postgresql-simple.pass"
db <- C.require conf "postgresql-simple.db"
adaptor <- setup id (ConnectInfo host port user pass db)
Rivet.main adaptor mode migrations
Once you've done that, build your project as normal, and then run the
produced migrate
binary. The main file provided has usage
instructions, though if you customize it, obviously these might vary.