PostgreSQL database in repository
Source control for PostgreSql Data base with git - Stack Overflow
Can I combine PostgreSQL with GitHub?
postgresql - postgres initialize with git - Stack Overflow
Videos
Hi, I’m a beginner at web development so I’m sorry for the dumb question but I recently made a project for a course I’m following that made use of a database I had created in PostgreSQL.
Now, I want to ask, if I want to upload this project on Github, how do I upload the database or the PostgreSQL content I used? What would be the right way of adding a project like that on my Github?
Generally the modern approach to doing this these days is to learn to use propel ORM or Doctrine ORM, which will version your database for you and keep the structure in sync as you commit the basic schema (in an xml format) and migrations.
PHP ORMs: Doctrine vs. Propel Has more about propel vs. doctrine.
You can use some tool that can generate text representation of db schema into files in some folder under vcs.
To see adequate working tree status you'll need to run schema generation before git status.
Before update from remote (git fetch && git rebase or git pull) you'll need to get db schema into worktree.
If that version differs from latest version in HEAD then you'll need to revert it in db or commit.
After update you'll need to get db schema into worktree again, check out diff and revert it in real db until db schema get will produce clean worktree.
P.S. I'm using this technique for MsSql db schemas in git. I even added db data to repo, this may be useful too.
I would like to maintain two versions of my database, on my local machine and on my server.
Is it possible for me to place the files, including postgres database, in my local machine in a repo and then clone it in my server?
Will it then run in my server?
My plan is to update my database locally because its much faster and is not breaking production, and then push the changes to the server via a git commit / pull request from the server.
Wanted to check if this works with Postgres?