schema-risk 0.1.3

Stop dangerous database migrations before they reach production
Documentation
# Publishing schema-risk to crates.io


This guide walks you through publishing schema-risk to the Rust package registry (crates.io).

## Pre-Flight Checklist ✅


Your project is ready to publish. Verification completed:

- `Cargo.toml` contains all required metadata (name, version, description, license, repository, keywords, categories, readme)
- ✅ Repository URL points to correct GitHub location
- ✅ Release profile optimized for binary size (lto=true, codegen-units=1, strip=true)
- ✅ CLI help output is professional and clear
-`cargo package` succeeds (36 files, 96.8KiB compressed)
- ✅ README demonstrates 5-second value with real output examples
- ✅ License file (MIT) included

## Step-by-Step Publishing


### Step 1: Get Your crates.io API Token


1. Visit [https://crates.io/me]https://crates.io/me
2. If not logged in, sign up (using GitHub OAuth is easiest)
3. Scroll down to "API Tokens"
4. Click **New Token**
5. Copy the token (you'll only see it once)

### Step 2: Login to Cargo


```bash
cargo login YOUR_API_TOKEN
```

This command:
- Stores your token in `~/.cargo/credentials.toml`
- You only need to do this once per machine
- The token is never committed to git

### Step 3: Final Verification


Run the package verification one more time:

```bash
cd path/to/schema-risk
cargo package
```

Expected output:
```
Packaging schema-risk v0.1.0
...
Verifying schema-risk v0.1.0
...
Finished `dev` profile
```

All 36 files should be included. If files are missing, add them to `Cargo.toml`:

```toml
[package]
...
readme = "README.md"
license-file = "LICENSE"
```

### Step 4: Publish


```bash
cargo publish
```

This will:
1. Verify the package
2. Upload to crates.io
3. Make it searchable and installable

**Expected output:**
```
Uploading schema-risk v0.1.0 to registry...
Uploaded schema-risk v0.1.0 to crates.io
```

### Step 5: Celebrate 🎉


Your crate is now live at: https://crates.io/crates/schema-risk

Users can install it with:
```bash
cargo install schema-risk
```

## Post-Publication Tasks


### Create a GitHub Release


Tag the release in git:

```bash
git tag v0.1.0
git push origin v0.1.0
```

Then manually create a GitHub release with:

1. **Title**: `v0.1.0 - Initial Release`
2. **Body** (use this template):

```markdown
## What's New


Initial release of schema-risk — production-grade PostgreSQL migration safety analyzer.

## Features


- Analyzes SQL migrations for production risks
- Interactive guard mode (requires human confirmation for dangerous operations)
- CI/CD integration (GitHub Actions, GitLab, CircleCI)
- Detailed impact analysis and recommendations

## Installation


```bash
cargo install schema-risk
```

## Quick Start


```bash
# Analyze a migration

schema-risk analyze migrations/001_add_users.sql

# Guard a dangerous migration (interactive)

schema-risk guard migrations/005_drop_orders.sql

# Check migrations in CI

schema-risk ci-report "migrations/*.sql" --format github-comment
```

## Links


- **Documentation**: https://docs.rs/schema-risk
- **Repository**: https://github.com/Ayuussshhh/schema-risk
- **Crates.io**: https://crates.io/crates/schema-risk
```

### Update Documentation

Your docs are automatically generated on [docs.rs/schema-risk](https://docs.rs/schema-risk) from your code:

```bash
# Add documentation comments to public items
/// Analyzes a migration file for risks
pub fn analyze_migration(path: &str) -> Result<Analysis> {
    // ...
}
```

Rebuild docs locally:
```bash
cargo doc --open
```

## Troubleshooting


### Error: "error: duplicate key"


This means your `Cargo.toml` has duplicate keys in a section. Check `[profile.release]` for duplicates.

### Error: "crate already exists at crates.io"


You can't overwrite a published version. Increment the version:

```toml
[package]
version = "0.2.0"  # Was 0.1.0
```

Then publish again:
```bash
cargo publish
```

### Error: "unauthorized"


Your API token is invalid or expired:

1. Generate a new token at https://crates.io/me
2. Run `cargo login NEW_TOKEN`
3. Try `cargo publish` again

## Version Strategy


**First release (0.1.0)**: Core features working
- `schema-risk analyze`
-`schema-risk guard` (with AI agent blocking)
-`schema-risk explain`
- ✅ CI integration

**Future versions**:
- 0.2.0: New features (e.g., config files, more rules)
- 0.3.0: Breaking API changes (if upgrading major Rust version)
- 1.0.0: Stable API guarantee

## Why schema-risk Will Gain Traction


1. **Solves Real Problem**: Prevents production outages from schema migrations
2. **Unique Guard Feature**: Interactive human confirmation + AI agent blocking
3. **Great DX**: One-command install, clear CLI, immediate value
4. **CI/CD Native**: Works in GitHub Actions, GitLab, CircleCI out of the box
5. **Clear Positioning**: "ESLint for database migrations"

Engineers will share this tool with their teams because it prevents outages.

## References


- [Cargo Book - Publishing]https://doc.rust-lang.org/cargo/reference/manifest.html
- [crates.io Help]https://crates.io/help
- [docs.rs]https://docs.rs