Registry / database / schema-seed-adapter-mysql

schema-seed-adapter-mysql

JSON →
library0.1.11jsnpmunverified

MySQL adapter for schema-seed (v0.1.11), a test-data seeding library for relational databases. This package is automatically loaded by schema-seed CLI when a MySQL connection string is detected. Current version is early (pre-1.0), with no active release cadence. Key differentiator: integrates seamlessly with schema-seed's schema-driven seeding approach for MySQL, allowing developers to define seed data in JSON/YAML and apply it directly to a MySQL database. Note: only compatible with mysql2 driver, not mysql proper. This adapter handles table creation, foreign key ordering, and data insertion.

npm install schema-seed-adapter-mysql
INSTALL
IMPORT
SIG · SCHEMA-SEED-ADAPTE
S
schema-seed-adapter-mysql
databasejavascriptv0.1.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import adapter from 'schema-seed-adapter-mysql'
import { adapter } from 'schema-seed-adapter-mysql'
Package exports a default adapter object; named import not available.
MySQLSeedAdapter
import MySQLSeedAdapter from 'schema-seed-adapter-mysql'
const { MySQLSeedAdapter } = require('schema-seed-adapter-mysql')
CommonJS require will return the default export as an object with ESM compatibility; use default import for clarity.
SeedConfig
import type { SeedConfig } from 'schema-seed'
import { SeedConfig } from 'schema-seed-adapter-mysql'
Type definitions for seed config are in schema-seed package, not the adapter.

Configures schema-seed with MySQL adapter and runs seeding from local seeds directory.

import schemaSeed from 'schema-seed'; import mysqlAdapter from 'schema-seed-adapter-mysql'; schemaSeed.configure({ adapter: mysqlAdapter, connection: { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test' }, seedDir: './seeds' }); await schemaSeed.seed(); console.log('Database seeded successfully.');
Debug
Known issues
gotchaAdapter only works with mysql2, not the older mysql package.
fix
Ensure your project has mysql2 installed and use mysql2 connection strings.
affects: >=0.1.0
gotchaTables are dropped and recreated each seed run by default; existing data will be lost.
fix
Set seedOptions.dropTable: false in config to preserve data, but be aware of potential conflicts.
affects: >=0.1.0
gotchaForeign key ordering is handled automatically but may fail if circular references exist.
fix
Avoid circular references in seed schema or manually order seed files.
affects: >=0.1.0
deprecatedThe adapter does not support connection pooling; each seed creates a single connection.
fix
Use schema-seed with a connection pool configuration if needed (future version).
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
mysql2 is not installed in the project.
fix
npm install mysql2
Error: ER_ACCESS_DENIED_ERROR: Access denied for user
Invalid database credentials provided in configuration.
fix
Check DB_HOST, DB_USER, DB_PASSWORD environment variables or config object.
TypeError: adapter is not a function
Imported default export incorrectly (e.g., used named import).
fix
Use default import: import adapter from 'schema-seed-adapter-mysql'
Error: Unknown database '...'
Database specified in config does not exist.
fix
Create the database first: CREATE DATABASE `your-db-name`;
Upgrade
Version history
0.1.11latest on npm
Audit
Dependencies
schema-seedrequiredpeer dependency - this adapter is consumed by schema-seed
mysql2requiredruntime dependency for MySQL database connection
Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
schema-seed-adapter-mysql — npm install schema-seed-adapter-mysql · libregistry