{"library":"squawk-cli","title":"squawk-cli: PostgreSQL Migration Linter","type":"library","description":"Squawk-cli is a linter for PostgreSQL migrations and SQL, designed to identify potentially dangerous operations that could lead to database locks, downtime, or compatibility issues. It helps prevent unexpected downtime by enforcing best practices for schema changes. The current version is 2.47.0. It maintains a relatively active release cadence, with multiple minor versions often released within a few weeks to months.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install squawk-cli"],"cli":{"name":"squawk","version":"squawk 2.52.1"}},"imports":[],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://squawkhq.com","github":"https://github.com/sbdchd/squawk","docs":null,"changelog":null,"pypi":"https://pypi.org/project/squawk-cli/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\n\n# Create a dummy SQL migration file\nsql_content = '''\n-- migration_001.sql\n\nCREATE TABLE users (\n    id serial NOT NULL PRIMARY KEY,\n    username varchar(255) NOT NULL,\n    email varchar(255) NOT NULL UNIQUE\n);\n\n-- This will trigger a warning in squawk if not handled concurrently\nCREATE INDEX email_idx ON users (email);\n\n-- This might also trigger a warning depending on Postgres version and rules\nALTER TABLE users ADD COLUMN age integer DEFAULT 18;\n'''\n\nfile_path = 'migration_001.sql'\nwith open(file_path, 'w') as f:\n    f.write(sql_content)\n\nprint(f\"Created {file_path}:\")\nprint(sql_content)\n\n# Run squawk-cli on the file\nprint(f\"\\nRunning squawk on {file_path}...\")\nos.system(f\"squawk {file_path}\")\n\n# Clean up the dummy file\nos.remove(file_path)\nprint(f\"\\nCleaned up {file_path}.\")","lang":"python","description":"This quickstart demonstrates how to install `squawk-cli` and run it against a sample SQL migration file to detect potential issues. It creates a temporary SQL file, executes `squawk` on it, and then cleans up the file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}