Bored again... PostgreSQL dev tool

  • Thread starter Deleted member 43669
  • Start date
Status
Not open for further replies.
D

Deleted member 43669

Guest
So I have some personal stuff to keep track of and quickly it outgrew what was sane to do in a Google Docs spreadsheet. So I turned to PostgreSQL...

My primary need is a database. I don't need or want an ORM. I can do my calculations and stuff using SQL functions and views. But I want my schema under version control, and I think migrations are not the central point of that- the schema is.

I also want flexibility in my development environment. I don't want to bother with my distro's Postgres package, as it might not match what I want to deploy, or what's packaged on other developers' distros.

So I came up with this crappy thing:

https://github.com/alexpdp7/pypgdev

Initially, all it does is allow you to start a PostgreSQL instance using Docker, storing the data folder in your filesystem, using a single, minimal command. It stays on the foreground until you CTRL+C it. You can copy the data folder and start a clone to play around without fuss. There's another command which opens a psql session for whatever container you want.

I have also added a crude schema diff tool; just point it to two data dirs and it will dump the schema and report the differences. Then you can write migrations if you need to, and run them until you ensure that it results in your desired schema.

My next step will be to define a directory structure to define a schema, which cleanly separates:

  • Table definitions (which cannot be reloaded easily)
  • Function/view definitions (which can be)
  • Tests
  • Test data
  • Data anonymization/reduction processes

, so you can automate common development workflows:

  • Restore a production database to a temporary instance, run anonymization/reduction processes and generate a packaged data folder you can use to develop
  • Edit functions, reload them and run tests
  • Modify the schema, compare it to your production database and iterate your migration code
  • ...

... thoughts? I've been unable to find something similar- which often means you're doing the wrong thing, but it looks like an interesting avenue to explore...
 
Status
Not open for further replies.