#database #postgres #birdseed #libellis #seeding

bin+lib birdseed

birdseed enables you to seed a libellis database with fake data, clear all tables, or rebuild all tables per the current embedded migrations

8 releases

✓ Uses Rust 2018 edition

new 0.1.7 Feb 13, 2019
0.1.6 Feb 9, 2019
0.1.4 Jan 23, 2019

#18 in #postgres

Download history 28/week @ 2019-01-16 27/week @ 2019-01-23 6/week @ 2019-01-30 23/week @ 2019-02-06

30 downloads per month

MIT license

36KB
747 lines

🐦 birdseed 🐦

Build Status crates.io MIT licensed Released API docs

This crate's entire purpose is to seed the libellis database with fake data (generated by faker library).

Setup

You MUST set a PSQL_URL environment variable to your libellis postgres database.

Example

$ export PSQL_URL=postgres://username:password@localhost/

Note the ending forward slash in the example above is required. You can optionally set this in a .env file in the root folder of this project if you are running the project from a local folder.

Installation

You may install this in one of two ways. If you have cargo installed then it's very easy. If not, you can install rust and cargo by following this very simple cargo setup process. Once you have cargo installed you can install this terminal application by running:

$ cargo install birdseed

Optionally you may instead clone this repo and in the root directory build the release version of this crate:

$ git clone https://github.com/libellis/birdseed.git
$ cd birdseed
$ cargo build --release

Features

feed

You can seed all databases with the feed subcommand:

$ birdseed feed

We can specify a row count (overriding the default of 1000 rows):

$ birdseed feed -r 10000

In this exampe we override the default of 1,000 rows and instead seed 10,000 rows.

Note: What the row count really means is that we will seed row count amount of users, surveys and questions, but row count * 4 amount of choices and votes.

setup

You can setup the main libellis and libellis_test databases with this subcommand. It will attempt to drop both libellis and libellis_test before creating them so be careful! Only use this if you don't need the data in your libellis database and want to start over, or are creating your libellis databases for the first time.

$ birdseed setup

migrate

To run migrations, use the migrate subcommand (this will update your database schema to the most recent schema).

$ birdseed migrate

By default this runs migrations on all databases. To run migrations on only main run:

$ birdseed migrate -d main

To run migrations only on the test database run:

$ birdseed migrate -d test

rebuild

You can rebuild all tables according to embedded diesel migrations. This drops each table (but does not drop the database itself) and then rebuilds all tables. Note that you must already have libellis and libellis_test databases for this to work. If you do not have those databases run birdseed setup instead.

$ birdseed rebuild

rebuild by default will rebuild all tables in both your main and test databases. If you would like to specify to only rebuild one database, pass in 'main' or 'test' to the -database argument flag:

$ birdseed rebuild -database main

You can also use -d for shorthand:

$ birdseed rebuild -d test

clear

You can clear all tables with the clear subcommand:

$ birdseed clear

Dependencies

~9MB
~154K SLoC