Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Latest commit

 

History

History
50 lines (36 loc) · 1.58 KB

README.md

File metadata and controls

50 lines (36 loc) · 1.58 KB

Herdwick

The Herdwick is a breed of domestic sheep native to the Lake District of Cumbria in North West England. The name "Herdwick" is derived from the Old Norse herdvyck, meaning sheep pasture.

Herdwick is also a library for easily populating databases with dummy data. It analyses database schema for foreign key references and other constraints to make generation of data as painless as possible.

Example

Consider the following database schema:

create table department (
    id serial primary key,
    name varchar(20) not null unique,
);

create table employee (
    id serial primary key,
    department_id int not null references department,
    name varchar(50) not null unique
);

To automatically populate the schema with valid values, you can use the following code:

Populator populator = Populator.forUrlAndCredentials("jdbc:example-url", "login", "password");

populator.populate("department", 50);
populator.populate("employee", 10000);

The populator.populate("department", 50) call will generate 50 random departments whose names will be unique and populator.populate("employee", 10000) will generate 10000 employees randomly assigned to those departments.

Integration with Dalesbred

If you are using Dalesbred, you can construct a new populator using your Database-instance:

Database db = ...
Populator populator = new Populator(db);

Like this you can integrate population with your existing transactions.