
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
p2p-schema
Advanced tools
A set of utilities for managing Prisma database schemas, seeding, and maintenance operations for the Procure-to-Pay system
A set of utilities for managing Prisma database schemas, seeding, and maintenance operations for the Procure-to-Pay system.
npm install p2p-schema
This package includes the full Prisma client generated from the schema, making it easy to use in your projects:
import { PrismaClient } from "p2p-schema";
// Create a new Prisma client instance
const prisma = new PrismaClient();
async function main() {
// Example: Query all users
const users = await prisma.user.findMany({
include: {
user_roles: {
include: {
role: true,
},
},
},
});
// Example: Create a new user
const newUser = await prisma.user.create({
data: {
email_id: "john@example.com",
name: "John Doe",
first_name: "John",
last_name: "Doe",
status: "Active",
user_roles: {
create: {
role: {
connect: { id: 1 }, // Connect to an existing role
},
},
},
},
});
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
// Close the database connection when done
await prisma.$disconnect();
});
The package provides three main command-line utilities:
Synchronize Prisma schema across multiple databases:
# Sync all databases
npx prisma-sync
# Sync a specific database
npx prisma-sync --db YOUR_DB_NAME
Seed one or multiple databases with data:
# Seed all databases
npx prisma-seed
# Seed a specific database
npx prisma-seed --db YOUR_DB_NAME
Truncate specific tables in one or multiple databases:
# Truncate specific tables in all databases
npx prisma-truncate --tables table1,table2,table3
# Truncate specific tables in a single database
npx prisma-truncate --db YOUR_DB_NAME --tables table1,table2,table3
# Use interactive mode to select tables
npx prisma-truncate --db YOUR_DB_NAME --interactive
# Truncate all tables except specific ones
npx prisma-truncate --tables all --exclude _prisma_migrations,tenant_configurations
# Dry run (preview without executing)
npx prisma-truncate --db YOUR_DB_NAME --tables users,posts --dry-run
You can also use the package programmatically:
import { syncDatabase, seedDatabase, truncateTables } from "p2p-schema";
// Sync schemas
syncDatabase({ db: "YOUR_DB_NAME" });
// Seed database
seedDatabase({ db: "YOUR_DB_NAME" });
// Truncate tables
truncateTables({
db: "YOUR_DB_NAME",
tables: ["users", "posts", "comments"],
exclude: ["migrations"],
dryRun: false,
noCascade: false,
noConfirm: true,
});
The package expects a standard Prisma configuration:
A .env
file in your prisma
directory containing database URLs in the format:
DATABASE_NAME_DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
DEFAULT_DATABASE_URL="postgresql://username:password@localhost:5432/default_db"
A Prisma schema file at prisma/schema.prisma
The Prisma schema included in this package contains models for a complete Procure-to-Pay system, including:
LOG_LEVEL
- Set logging level (debug, info, warn, error, silent)MIT © Azhar Pathan
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
FAQs
A set of utilities for managing Prisma database schemas, seeding, and maintenance operations for the Procure-to-Pay system
We found that p2p-schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.