News for hackers. Stuff that matters.
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by evangow on Thursday December 05, 2019 @02:08PM (#21715300)
This is a very cool project, but I'm not sure exactly what I would use it for. I could see it being useful if didn't start your project out using a tool for schema migrations and need to back reverse engineer things to create fake migrations.

I'm curious, does anyone here use it that would care to explain their use case?

Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by paps on Thursday December 05, 2019 @03:30PM (#21716159)
We use it in our CI, just before deployment, to compare the DB structure of what's being tested with the DB structure of our staging or production environment.

It's a last minute check that prevented a lot of mistakes.

Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by djrobstep on Thursday December 05, 2019 @09:35PM (#21718797)
You might be interested in the service I'm building, which does a similar thing in a more structured way: https://djrobstep.com/ci-for-databases
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by larkost on Thursday December 05, 2019 @07:32PM (#21718262)
Wouldn't a dump and then diff of the schema into text form accomplish the same thing?
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by hobs on Thursday December 05, 2019 @08:58PM (#21718656)
It absolutely should, though you might want to have a specific set of questions you ask in an ordered fashion as things like column order might differ between production and development due to data sizes, dropping and recreating dev instead of migration, etc.

None of those things actually being a problem could give you false positives, so you might want some minor shuffling.

Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by fanf2 on Thursday December 05, 2019 @07:56PM (#21718384)
Or something a bit more high-level like Migra? https://github.com/djrobstep/migra
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by sciolistse on Thursday December 05, 2019 @02:24PM (#21715491)
It seems like it could be used for declarative schema management (like https://www.skeema.io/) where you define the table structure you want in code and the application diffs a database and performs whatever changes is needed to reflect the requested schema.
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by stephen on Thursday December 05, 2019 @02:19PM (#21715444)
I'm using it generate a "flush_database()" stored procedure (after applying the latest migrations), that means each "before each" of a test can "execute flush_database" to get a clean slate db for its boundary case (w/o having to know/lookup "oh we've got 10-20-50 some entity tables now").

So, yeah, just custom/minor infrastructure/tooling stuff that is based on the db schema.

Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by aargh_aargh on Friday December 06, 2019 @03:40AM (#21720122)
Doesn't your RDBMS support transactions?
Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by djrobstep on Thursday December 05, 2019 @05:53PM (#21717592)
I have a similar project called `schemainspect` - It creates a data structure representation of a postgres schema.

I then use this data in my database diffing project `migra`, to autogenerate database migrations. You can also use schema diffing to test that your production and development databases match explicitly.

Overall it's a much more flexible but rigorous approach than the old-fashioned rails/django migrations.

Re:Get PostgreSQL Database Structure as a Detailed JavaScrip... by kristiandupont on Friday December 06, 2019 @02:35AM (#21719907)
I've made something similar which I use for two things. 1) I create typescript types from my schema, and 2) I run a "linter" over my schema that validates a number of rules that I've created. It's been a great help honestly.