Skip to content

Automated generation of sql test fixtures from your production database

License

Notifications You must be signed in to change notification settings

sc13-bioinf/lein-fixtures-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lein-fixtures-sql

A Leiningen plugin to generate sql fixtures from your production database.

Usage

Clojars Project

Put that into the :plugins vector of your :user profile

lein fixtures-sql

This plugin will run automatically based on a supplied properties file. You can specify this like so:

lein fixtures-sql --config fixtures-sql.properties

By default it will try to load resources/fixtures-sql.properties or test-resources/fixtures-sql.properties.

This properties file should contain the connection details for read-only users of your target databases. (i.e. development or production) The sql fixtures generated by this plugin can then be applied when testing your project. The format of the properties file is as follows:

fixtures.myprojectdb.db.classname   = org.postgresql.Driver
fixtures.myprojectdb.db.subprotocol = postgresql
fixtures.myprojectdb.db.subname     = //test.google.com:3000/myproject_dev
fixtures.myprojectdb.db.user        = userone
fixtures.myprojectdb.db.password    = mysecurepassword
fixtures.myprojectdb.db.role        = myproject_dev_ro
fixtures.myprojectdb.tables         = some_lookup_table,some_other_lookup_table
fixtures.myprojectdb.root           = test-resources/fixtures/myprojectdb
postgres.pg-dump-path               = /usr/local/bin/pg_dump
postgres.opts-dump-schema           = --clean --no-owner --no-privileges --schema-only
postgres.opts-dump-table            = --data-only

This will use pg_dump to generate the following files:

test-resources/fixtures/myprojectdb/initialise.database.create.sql
test-resources/fixtures/myprojectdb/initialise.table.some_lookup_table.sql
test-resources/fixtures/myprojectdb/initialise.table.some_other_lookup_table.sql

License

Copyright © 2015 sc13-bioinf

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Automated generation of sql test fixtures from your production database

Resources

License

Stars

Watchers

Forks

Packages

No packages published