agentsclimarketplace

Migrations

Skill ashutoshpw/stripe-sync-engine/skills/migrations

When the user wants to run database migrations for stripe-sync-engine. Also use when the user mentions "run migrations," "stripe schema," "create stripe tables," "database setup," or "stripe_migrations."From its SKILL.md

Install
npx -y skills add ashutoshpw/stripe-sync-engine --skill migrations

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.0 KB, as published. Nobody here has run it

Stripe Sync Engine Migrations

You are an expert in running and managing database migrations for stripe-sync-engine. Your goal is to help users set up the PostgreSQL schema required for syncing Stripe data.

Initial Assessment

Before proceeding, verify:

  1. Is stripe-sync-engine installed? If not, run the setup skill first.
  2. Is DATABASE_URL environment variable configured?
  3. Does the database user have permission to create schemas?

Running Migrations

Method 1: Create a Migration Script (Recommended)

Create scripts/run-migrations.ts:

import { runMigrations } from "stripe-sync-engine";

async function main() {
  if (!process.env.DATABASE_URL) {
    throw new Error("DATABASE_URL environment variable is not set");
  }

  console.log("Running Stripe sync engine migrations...");

  await runMigrations({
    databaseUrl: process.env.DATABASE_URL,
    schema: "stripe",
    tablePrefix: "",
    migrationTableName: "stripe_migrations",
  });

  console.log("Migrations completed successfully");
}

main().catch((error) => {
  console.error("Migration failed:", error);
  process.exit(1);
});

Add to package.json:

{
  "scripts": {
    "stripe:migrate": "tsx scripts/run-migrations.ts"
  }
}

Install tsx if needed:

npm install -D tsx

Run:

npm run stripe:migrate

Method 2: API Endpoint (For Serverless)

Create an API endpoint to trigger migrations:

Next.js App Router

Create app/api/migrations/run/route.ts:

import { runMigrations } from "stripe-sync-engine";
import { NextResponse } from "next/server";

export async function POST() {
  if (!process.env.DATABASE_URL) {
    return NextResponse.json(
      { error: "DATABASE_URL not configured" },
      { status: 500 }
    );
  }

  try {
    await runMigrations({
      databaseUrl: process.env.DATABASE_URL,
      schema: "stripe",
    });
    return NextResponse.json({ status: "migrated" });
  } catch (error) {
    const message = error instanceof Error ? error.message : "Unknown error";
    return NextResponse.json({ error: message }, { status: 500 });
  }
}

Hono

app.post('/migrations/run', async (c) => {
  await runMigrations({ databaseUrl, schema: 'stripe' });
  return c.json({ status: 'migrated' });
});

Migration Configuration Options

OptionTypeDescription
databaseUrlstringPostgreSQL connection string
schemastringDatabase schema name (default: stripe)
tablePrefixstringPrefix for all table names (default: empty)
migrationTableNamestringName of migrations tracking table (default: stripe_migrations)
sslobjectSSL connection options
loggerLoggerPino logger instance

Verifying Migrations

After running migrations, verify the schema was created:

-- Check schema exists
SELECT schema_name
FROM information_schema.schemata
WHERE schema_name = 'stripe';

-- List all created tables
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'stripe'
ORDER BY table_name;

-- Check migrations table
SELECT * FROM stripe.stripe_migrations ORDER BY id;

Tables Created

The migrations create these tables in the stripe schema:

TableDescription
customersCustomer records
productsProduct catalog
pricesPricing information
plansLegacy plan objects
subscriptionsSubscription records
subscription_itemsItems within subscriptions
invoicesInvoice records
invoice_line_itemsLine items on invoices
chargesCharge records
payment_intentsPayment attempts
payment_methodsSaved payment methods
setup_intentsSetup intent records
refundsRefund records
disputesDispute records
credit_notesCredit note records
couponsCoupon records
tax_idsTax ID records

Troubleshooting

Permission Denied

If you see permission errors:

-- Grant schema creation permission
GRANT CREATE ON DATABASE your_database TO your_user;

-- Or create schema manually first
CREATE SCHEMA IF NOT EXISTS stripe;
GRANT ALL ON SCHEMA stripe TO your_user;

PostgreSQL Version

stripe-sync-engine requires PostgreSQL 12+. Recommended: PostgreSQL 14+.

Check version:

SELECT version();

Connection Issues

Verify your connection string format:

postgresql://username:password@host:port/database?sslmode=require

For local development without SSL:

postgresql://username:password@localhost:5432/database

Related Skills

  • setup: Install and configure stripe-sync-engine
  • webhook: Set up webhook handlers after migrations
  • troubleshooting: Debug migration and connection issues

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.