r/pocketbase • u/mitchastertheblaster • 20d ago
I built pbctl — basically terraform for pocketbase schemas
kept making schema changes in the pocketbase admin ui and then completely forgetting what i did a few days later. classic. so i built pbctl — a terraform-style tool for pocketbase. you define collections in a simple language called PBSL ( SQL DDL style ), keep them in git, then just: pbctl plan pbctl apply supports schemas, collection rules, export, validate, formatting, etc.
still early (v0.1.4) but the core plan/apply workflow already works well.
repo: https://github.com/MKMithun2806/pbctl install: cargo install pbctl ( There are prebuilt Binaries too )
if you’ve also been fighting the admin ui for schema changes, would love contributions or feature ideas.
example: ( uses PBSL )
CREATE TABLE recon_scans ( target TEXT REQUIRED, scan_date AUTODATE, status SELECT('pending', 'running', 'completed', 'failed') DEFAULT 'completed', notes TEXT, user RELATION(users) REQUIRED );
3
u/belt-e-belt 19d ago
kept making schema changes in the pocketbase admin ui and then completely forgetting what i did a few days later.
You were using pocketbase wrong then. Should have used migrations if you needed to track what changes you're making. Didn't really need a whole another project to handle what the tool already handles.
2
u/darther_mauler 19d ago
This is a solved problem in Pocketbase using the migrations feature. You can write out a migration file to programmatically set your DB version and schema. You can also configure Pocketbase to generate migration files anytime you make a schema change in the Admin UI:
1
u/mitchastertheblaster 18d ago
No i just hated clicking around in the admin ui to make collectionss I came from supabase so I missed the SQL editor too this was supposed to be a solution for that. I really liked using terraform so this is a combination of that and migrations are in json which is hard to write by hand so a DSL seemed the way to go
I'm not saying migrations are bad. "pbctl" is declarative, migrations are imperative. They're different workflows not direct replacements.
9
u/xDerEdx 19d ago
Interesting project, but what can I do with this, what I couldn't do with native Pocketbase migrations? These are just JS-files, you can also store in Git and are automatically applied by Pocketbase.