Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 155 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,175 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# Cloud9 revision files
.c9revisions
*$py.class

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
lib
lib64
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.tox
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Mr Developer
.mr.developer.cfg
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install different versions of packages depending on
# the platform. Pipfile.lock may vary on different platforms. For example, if you are using Mac OS
# and your colleague is using Linux, with same Pipfile, Pipfile.lock may be different.
# In that case, it may be better to ignore Pipfile.lock and let the colleague generate it themselves.
# Also, if you are developing a library, ignoring Pipfile.lock is recommended.
# See pypa/pipenv#598 for the discussion.
# Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# The poetry.lock file stores exact versions of your dependencies, so you can recreate the same
# environment across different machines.
# However, if you are developing a library, ignoring poetry.lock is recommended.
# poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm.lock
# .pdm.toml

# PEP 582; used by e.g. pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# PyCharm files
.idea/
.project
.pydevproject
.settings/
*.iml
*.ipr
*.iws

# VSCode
.vscode/

# Sublimetext
*.sublime-project
*.sublime-workspace

# Mr Developer
.mr.developer.cfg
.mr.developer.ini

# Cloud9 revision files
.c_revisions

# macOS
.DS_Store
.AppleDouble
.LSOverride

# Windows
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump

# MyPy
.mypy_cache/
.dmypy.json
dmypy.json

# PyCharm
.idea
# Pyre type checker
.pyre/
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing to PgDiffPy

We welcome contributions to PgDiffPy! Here are some ways you can contribute:

## Reporting Issues

If you encounter a bug or have a feature request, please open an issue on our [GitHub issue tracker](https://github.com/Dancer3809/PgDiffPy/issues).

When reporting a bug, please include the following information:

* A clear and descriptive title.
* The version of PgDiffPy you are using.
* The steps to reproduce the bug.
* The expected behavior and the actual behavior.
* Any relevant error messages or stack traces.

## Submitting Pull Requests

If you would like to contribute code to the project, please follow these steps:

1. Fork the repository on GitHub.
2. Create a new branch for your feature or bug fix.
3. Make your changes and commit them with a clear and descriptive commit message.
4. Push your changes to your forked repository.
5. Open a pull request to the `main` branch of the original repository.

Please ensure that your code adheres to the existing code style and that all tests pass before submitting a pull request.
3 changes: 3 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This project is a Python port of the original [apgdiff](http://apgdiff.com/) tool. All credit for the original logic and concept goes to the apgdiff team.

This project is based on the work of [PgDiffPy](https://github.com/Gesha3809/PgDiffPy).
68 changes: 63 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@
PgDiffPy
=========
# PgDiffPy

[![Build Status](https://travis-ci.org/Dancer3809/PgDiffPy.png)](https://travis-ci.org/[Dancer3809/PgDiffPy)
[![Build Status](https://travis-ci.org/Dancer3809/PgDiffPy.png)](https://travis-ci.org/Dancer3809/PgDiffPy)

Diff tool for Postgresql database based on apgdiff but written in Python
## Purpose

PgDiffPy is a command-line tool for comparing two PostgreSQL database schema dumps and generating a SQL script to update the old schema to match the new one. It is based on the original apgdiff tool but rewritten in Python.

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Dancer3809/pgdiffpy/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
This tool is useful for database administrators and developers who need to manage and version-control their database schemas. It simplifies the process of deploying schema changes from a development environment to a production environment.

## Installation

You can install PgDiffPy directly from the source repository using `pip`. It is recommended to do this within a Python virtual environment to avoid conflicts with system-wide packages.

1. **Clone the repository:**
```bash
git clone https://github.com/Dancer3809/PgDiffPy.git
cd PgDiffPy
```

2. **Install the package:**
```bash
pip install .
```

This will install the `pgdiff` command-line tool and its dependencies. If you are using a virtual environment, the command will be available directly in your shell.

### Alternative: Installing for the Current User

If you prefer not to use a virtual environment, you can install the package for your user account:

```bash
pip install --user .
```

This installs the package in your user's local directory (e.g., `~/.local`). To run the `pgdiff` command directly, you may need to add the local bin directory (e.g., `~/.local/bin`) to your shell's `PATH`.

## Usage

Once installed, you can use the `pgdiff` command-line tool to compare two database dumps:

```bash
pgdiff [options] <old_dump.sql> <new_dump.sql>
```

### Arguments

* `old_dump.sql`: The path to the SQL file containing the old database schema.
* `new_dump.sql`: The path to the SQL file containing the new database schema.

### Options

* `--add-transaction`: Adds `START TRANSACTION` and `COMMIT TRANSACTION` to the generated diff file.
* `--add-defaults`: Adds `DEFAULT ...` in case a new column has a `NOT NULL` constraint but no default value.
* `--ignore-start-with`: Ignores `START WITH` modifications on `SEQUENCE`s.
* `--ignore-function-whitespace`: Ignores multiple spaces and new lines when comparing function content.

### Example

```bash
pgdiff original_schema.sql new_schema.sql > migration_script.sql
```

This will generate a `migration_script.sql` file that you can run on the original database to apply the schema changes.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Loading