Crates.io | birdseed |
lib.rs | birdseed |
version | 0.2.0 |
source | src |
created_at | 2019-01-21 05:41:10.388908 |
updated_at | 2019-03-05 06:44:35.006446 |
description | birdseed enables you to seed a libellis database with fake data, clear all tables, or rebuild all tables per the current embedded migrations |
homepage | |
repository | https://github.com/libellis/birdseed |
max_upload_size | |
id | 109757 |
size | 64,380 |
This crate's entire purpose is to seed the libellis database with fake data (generated by faker library).
You MUST set a PSQL_URL
environment variable to your libellis postgres database.
$ 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.
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
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
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
fences
You can load in fence data from a geojson file with the fences subcommand:
$ birdseed fences
By default it looks for a file called fences.json
in the data folder from the root of this
crate. This folder only exists if you cloned the repo. To specify a filepath yourself pass the
-f or -file flag after the fences subcommand:
$ birdseed fences -f BerkeleyNeighborhoods.json
Note: This only works if you have a fences table - which would have been setup for you from the
most recent migrations when running birdseed setup
or birdseed migrate
.
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.
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
clear
You can clear all tables with the clear
subcommand:
$ birdseed clear
icecream
For fun and profit you can seed the database with an row count amount of users, a single poll about icecream, and then populate that poll with fake votes from your newly faked user pool, and have all of their votes counted from legitimate randomized locations within the city of San Francisco.
$ birdseed icecream
By default the row count is 1000, and can be overriden in the same way as when using the feed
subcommand:
$ birdseed icecream -r 10000