psql schema to json migration and back again

Viewed 36

Hi I have a question I am using postresql with simple tables and I was wandering, if there is a possibility to export and import database schema as json document. For example:

CREATE TABLE Persons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    City varchar(255)
);

it would transform into something like:

"Persons":{
  "properties":{
     "PersonID ":{
        "type":"integer"
        "keys": //something definging key and relation 
     },
     "FirstName ":{
        "FirstName":"text"
     },
     "LastName ":{
        "type":"text"
     },
     "City":{
        "type":"text"
     }
  }

}

Reason is that I want to create a simple dynamic migration mechanics.

I could not find any sources to do this, nor any migrator. Is such import/export to postgresql is possible?

0 Answers
Related