Metadata-Version: 2.4
Name: locksafe
Version: 0.2.0
Summary: Postgres migration safety analyzer — catch dangerous operations before they run
Project-URL: Homepage, https://locksafe.dev
Project-URL: Repository, https://github.com/yourusername/locksafe
Project-URL: Issues, https://github.com/yourusername/locksafe/issues
License: MIT
Keywords: ci-cd,database,migrations,postgres,safety
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.12
Requires-Dist: click>=8.1.0
Requires-Dist: rich>=13.0.0
Requires-Dist: sqlglot[c]>=25.0.0
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
Requires-Dist: typing-extensions>=4.12.0
Provides-Extra: api
Requires-Dist: asyncpg>=0.29.0; extra == 'api'
Requires-Dist: boto3>=1.35.0; extra == 'api'
Requires-Dist: fastapi>=0.115.0; extra == 'api'
Requires-Dist: pydantic>=2.0.0; extra == 'api'
Requires-Dist: python-multipart>=0.0.9; extra == 'api'
Requires-Dist: razorpay>=1.4.0; extra == 'api'
Requires-Dist: sentry-sdk[fastapi]>=2.0.0; extra == 'api'
Requires-Dist: uvicorn[standard]>=0.30.0; extra == 'api'
Provides-Extra: dev
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: mypy>=1.11.0; extra == 'dev'
Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.7.0; extra == 'dev'
Description-Content-Type: text/markdown

# LockSafe AI

**LockSafe AI** is a CLI tool that analyzes PostgreSQL migration files and detects operations that can cause production downtime or data loss.

It helps you catch unsafe migrations **before they are applied**.

---

## Installation

```bash
pip install locksafe
```

Requires **Python 3.12+**

---

## Usage

Analyze a migration file:

```bash
locksafe analyze migration.sql
```

---

## Example

### Input

```sql
CREATE INDEX idx_users_email ON users(email);

ALTER TABLE users ADD COLUMN status TEXT NOT NULL;

TRUNCATE payments;
```

### Output

```
🔐 LockSafe Analysis
File: migration.sql
Statements: 3 │ Critical: 2 │ High: 0 │ Medium: 0 │ Low: 0

⚠ Migration risks detected

🔴 [CRITICAL] Statement 1
↳ CREATE INDEX without CONCURRENTLY on table 'users'

🔴 [CRITICAL] Statement 2
↳ ADD COLUMN NOT NULL without DEFAULT causes table rewrite

🔴 [CRITICAL] Statement 3
↳ TRUNCATE destroys all rows in payments
```

---

## Severity Levels

| Level | Meaning |
|------|--------|
| 🔴 CRITICAL | High risk of downtime or data loss |
| 🟠 HIGH | Likely to cause production issues |
| 🟡 MEDIUM | May cause performance or locking issues |
| 🔵 LOW | Informational or minor risk |

---

## Exit Codes

LockSafe returns exit codes for CI/CD usage:

| Code | Meaning |
|------|--------|
| `0` | No issues found |
| `1` | Issues detected |
| `2` | SQL parsing error |

---

## Debug Mode

Enable debug logs:

```bash
locksafe --debug analyze migration.sql
```

---

## CI/CD Usage

Use LockSafe in your pipeline to block unsafe migrations:

```bash
locksafe analyze migrations/0042_add_user_index.sql
```

If risks are detected, the command exits with code `1`.

---

## Tips

- Always review **CRITICAL** findings before running migrations
- Use `CONCURRENTLY` for index operations on large tables
- Avoid schema changes that rewrite entire tables in production

---

## License

MIT License