import click
from app import create_app, db
from app.models import User, Plan

app = create_app()

@app.cli.command("init-db")
def init_db():
    db.create_all()
    click.echo("Database initialized.")

@app.cli.command("seed-plans")
def seed_plans():
    plans = [
        {"code": "free", "name": "Free", "monthly_lookup_limit": 25, "price_cents": 0},
        {"code": "pro", "name": "Pro", "monthly_lookup_limit": 500, "price_cents": 4900},
    ]
    for p in plans:
        if not Plan.query.filter_by(code=p["code"]).first():
            db.session.add(Plan(**p))
    db.session.commit()
    click.echo("Plans seeded.")
