{"id":31692530,"url":"https://github.com/sqldef/sqldef-preview-action","last_synced_at":"2026-05-14T12:33:36.121Z","repository":{"id":316247606,"uuid":"1062585941","full_name":"sqldef/sqldef-preview-action","owner":"sqldef","description":"Preview how sqldef migration performs in pull requests","archived":false,"fork":false,"pushed_at":"2026-04-30T09:26:19.000Z","size":4603,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T11:18:04.054Z","etag":null,"topics":["github-actions","sqldef"],"latest_commit_sha":null,"homepage":"https://github.com/sqldef/sqldef","language":"TypeScript","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/sqldef.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-09-23T13:03:11.000Z","updated_at":"2026-04-30T09:25:20.000Z","dependencies_parsed_at":"2025-09-26T06:18:36.381Z","dependency_job_id":"22664616-6d07-4149-ac03-46d72cda54b3","html_url":"https://github.com/sqldef/sqldef-preview-action","commit_stats":null,"previous_names":["gfx/sqldef-preview-action","sqldef/sqldef-preview-action"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sqldef/sqldef-preview-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqldef%2Fsqldef-preview-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqldef%2Fsqldef-preview-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqldef%2Fsqldef-preview-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqldef%2Fsqldef-preview-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqldef","download_url":"https://codeload.github.com/sqldef/sqldef-preview-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqldef%2Fsqldef-preview-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33025053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["github-actions","sqldef"],"created_at":"2025-10-08T14:53:39.450Z","updated_at":"2026-05-14T12:33:36.114Z","avatar_url":"https://github.com/sqldef.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLDef Preview Action\n\n[![CI](https://github.com/sqldef/sqldef-preview-action/actions/workflows/ci.yaml/badge.svg)](https://github.com/sqldef/sqldef-preview-action/actions/workflows/ci.yaml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nA GitHub Action that previews SQL schema migrations of [sqldef](https://github.com/sqldef/sqldef) on pull requests. It automatically generates a preview of schema changes between your base branch and PR branch, posting the migration DDL as a comment on your pull request.\n\n## Features\n\n- **Automatic Schema Diff Preview**: Automatically compares schema changes between branches and displays the migration SQL\n- **Multiple Database Support**: Works with PostgreSQL, MySQL, SQLite, and SQL Server\n- **PR Comments**: Posts schema changes as comments on pull requests for easy review\n\n## How It Works\n\nWhen triggered on a pull request, this action:\n\n1. Downloads the appropriate sqldef binary for your database\n2. Sets up database connection using provided credentials\n3. Fetches the schema file from the base branch (baseline schema)\n4. Applies the baseline schema to the database\n5. Applies the new schema from the PR branch and captures the output\n6. Posts the schema changes as a comment on the pull request\n\n## Usage\n\n### Basic Example (PostgreSQL)\n\n```yaml\nname: Preview Schema Changes\n\non:\n  pull_request:\n    paths:\n      - 'schema/**/*.sql'\n\npermissions:\n  contents: read\n  pull-requests: write\n\njobs:\n  preview-schema:\n    runs-on: ubuntu-latest\n\n    services:\n      postgres:\n        image: postgres:15\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: testdb\n        options: \u003e-\n          --health-cmd pg_isready\n          --health-interval 10s\n          --health-timeout 5s\n          --health-retries 5\n        ports:\n          - 5432:5432\n\n    steps:\n      - uses: actions/checkout@v6\n        with:\n          fetch-depth: 0  # Required to fetch base branch\n\n      - uses: sqldef/sqldef-preview-action@v1\n        with:\n          command: psqldef\n          schema-file: schema/database.sql\n          pg-user: postgres\n          pg-password: postgres\n          pg-database: testdb\n          github-token: ${{ github.token }}\n```\n\n### MySQL Example\n\n```yaml\njobs:\n  preview-schema:\n    runs-on: ubuntu-latest\n\n    services:\n      mysql:\n        image: mysql:8.0\n        env:\n          MYSQL_ROOT_PASSWORD: testpassword\n          MYSQL_DATABASE: testdb\n        options: \u003e-\n          --health-cmd \"mysqladmin ping -h localhost\"\n          --health-interval 10s\n          --health-timeout 5s\n          --health-retries 10\n        ports:\n          - 3306:3306\n\n    steps:\n      - uses: actions/checkout@v6\n        with:\n          fetch-depth: 0\n\n      - uses: sqldef/sqldef-preview-action@v1\n        with:\n          command: mysqldef\n          schema-file: schema/database.sql\n          mysql-user: root\n          mysql-password: testpassword\n          mysql-host: 127.0.0.1\n          mysql-database: testdb\n          github-token: ${{ github.token }}\n```\n\n### SQLite Example\n\n```yaml\n- uses: sqldef/sqldef-preview-action@v1\n  with:\n    command: sqlite3def\n    schema-file: schema/database.sql\n    sqlite-database: test.db\n    github-token: ${{ github.token }}\n```\n\n### SQL Server Example\n\n```yaml\njobs:\n  preview-schema:\n    runs-on: ubuntu-latest\n\n    services:\n      mssql:\n        image: mcr.microsoft.com/mssql/server:2022-latest\n        env:\n          ACCEPT_EULA: Y\n          SA_PASSWORD: YourStrong@Passw0rd\n        options: \u003e-\n          --health-cmd \"/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P YourStrong@Passw0rd -Q 'SELECT 1' -C\"\n          --health-interval 10s\n          --health-timeout 5s\n          --health-retries 10\n          --health-start-period 20s\n        ports:\n          - 1433:1433\n\n    steps:\n      - uses: actions/checkout@v6\n        with:\n          fetch-depth: 0\n\n      - name: Create database\n        run: |\n          sudo apt-get update \u0026\u0026 sudo apt-get install -y curl gnupg\n          curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc\n          curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list\n          sudo apt-get update\n          sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18\n          /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P \"YourStrong@Passw0rd\" -Q \"CREATE DATABASE testdb;\" -C\n\n      - uses: sqldef/sqldef-preview-action@v1\n        with:\n          command: mssqldef\n          schema-file: schema/database.sql\n          mssql-user: SA\n          mssql-password: YourStrong@Passw0rd\n          mssql-database: testdb\n          github-token: ${{ github.token }}\n```\n\n## Input Parameters\n\n### Required Parameters\n\n| Parameter | Description | Required |\n|-----------|-------------|----------|\n| `command` | SQLDef command to use: `psqldef`, `mysqldef`, `sqlite3def`, or `mssqldef` | ✅ |\n| `schema-file` | Path to the SQL schema file | ✅ |\n| `github-token` | GitHub token for commenting on pull requests | ✅ |\n\n### Optional Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `version` | Version of sqldef to use (`latest` for the latest version) | `v3.0.3` |\n| `config-file` | Path to sqldef config file | - |\n\n### PostgreSQL Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `pg-user` | PostgreSQL user | - |\n| `pg-password` | PostgreSQL password | - |\n| `pg-host` | PostgreSQL host | `localhost` |\n| `pg-port` | PostgreSQL port | `5432` |\n| `pg-database` | PostgreSQL database name | - |\n\n### MySQL Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `mysql-user` | MySQL user | - |\n| `mysql-password` | MySQL password | - |\n| `mysql-host` | MySQL host | `localhost` |\n| `mysql-port` | MySQL port | `3306` |\n| `mysql-database` | MySQL database name | - |\n\n### SQLite Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `sqlite-database` | SQLite database file path | - |\n\n### SQL Server Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `mssql-user` | SQL Server user | - |\n| `mssql-password` | SQL Server password | - |\n| `mssql-host` | SQL Server host | `localhost` |\n| `mssql-port` | SQL Server port | `1433` |\n| `mssql-database` | SQL Server database name | - |\n\n## Example PR Comment\n\nWhen schema changes are detected, the action posts a comment like this:\n\n```sql\n## SQLDef Migration Preview\n\n~~~sql\nALTER TABLE users ADD COLUMN email VARCHAR(255) NULL;\nCREATE INDEX idx_users_email ON users(email);\n~~~\n```\n\n## Development\n\n### Building from Source\n\n```bash\n# Install dependencies\nnpm ci\n\n# Build TypeScript\nnpm run build\n\n# Package for distribution\nnpm run package\n\n# Run all checks and build packages\nnpm run all\n```\n\n### Running Tests\n\nExample workflows are provided in [.github/workflows/example.yaml](.github/workflows/example.yaml) that demonstrate usage with all supported databases.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqldef%2Fsqldef-preview-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqldef%2Fsqldef-preview-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqldef%2Fsqldef-preview-action/lists"}