Crates.io | trekker |
lib.rs | trekker |
version | 0.2.2 |
source | src |
created_at | 2023-10-15 00:27:44.248383 |
updated_at | 2023-10-15 00:27:44.248383 |
description | A command line tool to help you manage your PostgreSQL database migrations and seeds. |
homepage | |
repository | |
max_upload_size | |
id | 1003361 |
size | 35,337 |
Manage database migrations and seeds. Trekker is an incredibly specific tool used to migrate and seed databases. It does this in a very simplistic manner and I'd be surprised if I ever make it do more. I use it in my workflows and it's useful for me.
cargo install trekker
Trekker uses the DATABASE_URL
variable to connect to your Postgres database.
Trekker expects that you'll keep migrations in a particular directory.
Writing a migration entails creating a file, db/migrations/001-add-reddit-subreddits.sql
, with the migration SQL:
create table if not exists subreddits (
id serial primary key,
subreddit varchar not null unique
);
I use a three digit padded prefix to control execution order but you could also use a timestamp or date.
To run all of the migrations, use the migrate command:
trekker migrate db/migrations
Trekker expects that you'll keep seeds in a particular directory.
Writing a seed entails creating a file, db/seeds/001-add-some-subreddits.sql
, with the seed SQL:
insert into subreddits (subreddit) values
('mechmarket'),
('hardwareswap')
;
I use a three digit padded prefix to control execution order but you could also use a timestamp or date.
To run all of the seeds, use the seed command:
trekker seed db/seeds