{"id":22517566,"url":"https://github.com/spaceshaman/sqlift","last_synced_at":"2026-02-10T19:34:59.818Z","repository":{"id":266702340,"uuid":"897477219","full_name":"SpaceShaman/SQLift","owner":"SpaceShaman","description":"Simple CLI migration tool for SQL databases","archived":false,"fork":false,"pushed_at":"2025-01-26T16:57:55.000Z","size":149,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-26T17:30:03.608Z","etag":null,"topics":["cli","database","migration","postgres","postgresql","sql","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/SQLift/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpaceShaman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-02T17:41:30.000Z","updated_at":"2025-01-26T16:57:55.000Z","dependencies_parsed_at":"2024-12-05T16:47:59.263Z","dependency_job_id":"e5a9c8d9-4a29-4856-bbfa-a663b78df6c4","html_url":"https://github.com/SpaceShaman/SQLift","commit_stats":null,"previous_names":["spaceshaman/sqlift"],"tags_count":6,"template":false,"template_full_name":"SpaceShaman/pypi-workflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FSQLift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FSQLift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FSQLift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FSQLift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpaceShaman","download_url":"https://codeload.github.com/SpaceShaman/SQLift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236748978,"owners_count":19198619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","database","migration","postgres","postgresql","sql","sqlite","sqlite3"],"created_at":"2024-12-07T04:09:48.742Z","updated_at":"2026-02-10T19:34:59.810Z","avatar_url":"https://github.com/SpaceShaman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/SpaceShaman/SQLift/refs/heads/master/assets/logo-light.png\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/SpaceShaman/SQLift/refs/heads/master/assets/logo-dark.png\" alt=\"SQLift\"\u003e\n\u003c/picture\u003e\n\n[![GitHub License](https://img.shields.io/github/license/SpaceShaman/SQLift)](https://github.com/SpaceShaman/SQLift?tab=MIT-1-ov-file)\n[![Tests](https://img.shields.io/github/actions/workflow/status/SpaceShaman/SQLift/release.yml?label=tests)](https://app.codecov.io/github/SpaceShaman/SQLift)\n[![Codecov](https://img.shields.io/codecov/c/github/SpaceShaman/SQLift)](https://app.codecov.io/github/SpaceShaman/SQLift)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/SQLift)](https://pypi.org/project/SQLift)\n[![PyPI - Version](https://img.shields.io/pypi/v/SQLift)](https://pypi.org/project/SQLift)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)\n[![Linting: Ruff](https://img.shields.io/badge/linting-Ruff-black?logo=ruff\u0026logoColor=black)](https://github.com/astral-sh/ruff)\n[![SQLite](https://img.shields.io/badge/technology-SQLite-blue?logo=sqlite\u0026logoColor=blue)](https://www.sqlite.org)\n[![PostgreSQL](https://img.shields.io/badge/technology-PostgreSQL-blue?logo=postgresql\u0026logoColor=blue)](https://www.postgresql.org)\n[![Pytest](https://img.shields.io/badge/testing-Pytest-red?logo=pytest\u0026logoColor=red)](https://docs.pytest.org/)\n\nSQLift is a simple CLI migration tool for SQL databases. It is designed to be easy to use and now supports [SQLite](https://www.sqlite.org) and [PostgreSQL](https://www.postgresql.org) databases.\n\n## Installation\n\nYou can install SQLift using pip:\n\n```bash\npip install SQLift\n```\n\nBy default, SQLift uses [SQLite](https://www.sqlite.org) as the database. If you want to use [PostgreSQL](https://www.postgresql.org), you need to install the appropriate database driver.\nYou can do this using the following command:\n\n```bash\npip install SQLift[postgres]\n```\n\n## Usage\n\nFirst you need to create a 'migrations' directory where you will store your migration files.\nMigrations are simple SQL files that contain the SQL commands to be executed for `up` and `down` migrations like below.\nThis file needs two sections, one for the `up` migration and one for the `down` migration, separated by `--DOWN`.\n\n### Example migration file\n\n```sql\nmigrations/001_create_table.sql \n--UP\nCREATE TABLE IF NOT EXISTS test (\n    id INTEGER PRIMARY KEY\n);\n\n--DOWN\nDROP TABLE IF EXISTS test;\n```\n\nYou can find more examples of migration files in the [migrations](https://github.com/SpaceShaman/SQLift/tree/master/migrations) directory of this repository.\n\nAfter you have created your migration files, you can run the following command to apply the migrations to your database. (It is recommended to start the migration files with a number to keep them in order)\n\n```bash\nsqlift up\n```\n\nThis will apply all the migrations that have not been applied yet. If you want migrate to a specific version, you can pass the version as an argument.\n\n```bash\nsqlift up 001_create_table\n```\n\nTo rollback all migrations, you can run the following command.\n\n```bash\nsqlift down\n```\n\nTo rollback to a specific version, you can pass the version\n\n```bash\nsqlift down 001_create_table\n```\n\nYou can also select specific path for migrations directory\n\n```bash\nsqlift up --path /path/to/migrations\n```\n\n## Configuration\n\nSQLift uses environment variables to configure the database connection. You can set the following environment variables to configure the database connection.\n\n```env\nDB_URL=postgresql://user:password@localhost:5432/database # PostgreSQL\nDB_URL=sqlite:///path/to/database.db                      # SQLite\n```\n\nIf you don't set the `DB_URL` environment variable, SQLift will default to using [SQLite](https://www.sqlite.org) with a database file named `db.sqlite` in the current directory.\n\n## Contributing\n\nContributions are welcome! Feel free to open an issue or submit a pull request.\nI would like to keep the library to be safe as possible, so i would appreciate if you cover any new feature with tests to maintain 100% coverage.\n\n### Install in a development environment\n\n1. First, clone the repository:\n\n    ```bash\n    git clone git@github.com:SpaceShaman/SQLift.git\n    ```\n\n2. Install poetry if you don't have, here you can find the [instructions](https://python-poetry.org/docs/#installing-with-the-official-installer)\n\n3. Create a virtual environment and install the dependencies:\n\n    ```bash\n    cd SQLift\n    poetry install --no-root\n    ```\n\n4. Activate the virtual environment:\n\n    ```bash\n    poetry shell\n    ```\n\n### Run tests\n\nFirst, you need to run databases and you can do it simply with docker-compose:\n\n```bash\ndocker compose up -d\n```\n\nThen you can run the tests with pytest:\n\n```bash\npytest\n```\n\nYou can also run the tests with coverage:\n\n```bash\npytest --cov=sqlift\n```\n\n### Database clients\n\nIf you want to add support for a new database, you need to create a new client class that is consistent with the `Client` protocol class from [sqlift.clients](https://github.com/SpaceShaman/SQLift/blob/master/sqlift/clients.py) and implement the `execute` method. Look at the `SQLiteClient` and `PostgreSQLClient` classes for reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceshaman%2Fsqlift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaceshaman%2Fsqlift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceshaman%2Fsqlift/lists"}