{"id":49481,"library":"sworm-schema","title":"sworm-schema","description":"Schema utilities for testing databases with SWORM ORM. Current stable version is 1.2.2. It automates creating, deleting, and cleaning test databases, and can validate schema compatibility with queries. Designed for testing workflows, tightly integrated with SWORM (peer dependency ^3.7). Release cadence is low, primarily maintenance.","status":"maintenance","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/featurist/sworm-schema","tags":["javascript","sworm","sql","test","schema"],"install":[{"cmd":"npm install sworm-schema","lang":"bash","label":"npm"},{"cmd":"yarn add sworm-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add sworm-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required at runtime for database connections and query execution.","package":"sworm","optional":false}],"imports":[{"note":"Package is CommonJS only; named export via destructuring. No default export. ESM import will fail.","wrong":"import { SwormSchema } from 'sworm-schema'","symbol":"SwormSchema","correct":"const { SwormSchema } = require('sworm-schema')"},{"note":"Common mistake: treating it as default export. SwormSchema is not a default export; you must destructure.","wrong":"const SwormSchema = require('sworm-schema')","symbol":"SwormSchema (default import mistake)","correct":"const { SwormSchema } = require('sworm-schema')"},{"note":"Constructor requires both 'url' and 'schema' options. Missing required options will throw.","wrong":"const schema = new SwormSchema()","symbol":"Constructor usage","correct":"const { SwormSchema } = require('sworm-schema'); const schema = new SwormSchema({ url: 'sqlite:test.db', schema: { ... } })"}],"quickstart":{"code":"const { SwormSchema } = require('sworm-schema');\n\nconst swormSchema = new SwormSchema({\n  url: 'sqlite:test/db/test.db',\n  schema: {\n    people: {\n      id: { type: 'integer' },\n      name: { type: 'text' },\n    },\n    places: {\n      id: { type: 'integer' },\n      name: { type: 'text' },\n    },\n  },\n});\n\nasync function run() {\n  await swormSchema.create();\n  const db = await swormSchema.connect();\n  const person = db.model({ table: 'people' });\n  await person({ id: 1, name: 'Alice' }).save();\n  console.log(await db.query('select * from people'));\n  await swormSchema.clean();\n  await swormSchema.drop();\n}\nrun().catch(console.error);","lang":"javascript","description":"Creates an in-memory SQLite database from a schema definition, inserts a record, queries it, then cleans and drops the database."},"warnings":[{"fix":"Use const { SwormSchema } = require('sworm-schema') instead of const SwormSchema = require('sworm-schema').","message":"SwormSchema is not a default export; you must destructure from the require.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the URL is compatible with SWORM (e.g., sqlite:path, mysql://...). See SWORM docs for valid formats.","message":"The 'url' option must be a valid database connection string supported by SWORM. Incorrect strings may cause silent failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider alternative ORMs if active development is needed.","message":"SWORM itself may be in maintenance mode; check sworm package status for long-term stability.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always specify a type property for each column, e.g., id: { type: 'integer' }.","message":"The 'schema' option columns must include 'type'. Omitting type may cause validation errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.2':16 '3.7':42 'autom':18 'cadenc':44 'clean':22 'compat':29 'creat':19 'current':12 'databas':8,24 'delet':20 'depend':41 'design':32 'integr':37 'javascript':49 'low':46 'mainten':48 'orm':11 'peer':40 'primarili':47 'queri':31 'releas':43 'schema':3,4,28,53 'sql':51 'stabl':13 'sworm':2,10,39,50 'sworm-schema':1 'test':7,23,34,52 'tight':36 'util':5 'valid':27 'version':14 'workflow':35","created_at":"2026-06-07T17:01:59.623088+00:00","updated_at":"2026-06-07T17:01:59.623088+00:00","problems":[{"fix":"const { SwormSchema } = require('sworm-schema')","cause":"Importing SwormSchema as default instead of named export.","error":"TypeError: SwormSchema is not a constructor"},{"fix":"Ensure new SwormSchema() is called with correct options and all methods are awaited.","cause":"SwormSchema instance not properly created or async methods called without await.","error":"Cannot read property 'connect' of undefined"},{"fix":"Add type to each column, e.g., id: { type: 'integer' }.","cause":"Column definition in schema object lacks 'type' property.","error":"Error: Invalid schema definition: missing type for column 'id'"},{"fix":"Install sworm@^3.7 as a peer dependency.","cause":"SWORM peer dependency missing or incompatible version.","error":"Error: sworm is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/featurist/sworm-schema#readme","github":"https://github.com/featurist/sworm-schema","docs":null,"changelog":null,"pypi":null,"npm":"sworm-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}