Apply the numbered migrations (a folder or a list) that a database does not have, in one transaction
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/sqlite/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["sqlite","migrate"], {});
console.log(JSON.stringify(result));From the command line
$ mark sqlite migrate
As data, in a program
{ "$proc": ["sqlite", "migrate"], "input": {} }JSON Schemas
{
"input": {
"type": "object",
"properties": {
"folder": {
"description": "A folder of files named <number>_<name>.sql, for example 001_create_users.sql (not with migrations)",
"type": "string",
"minLength": 1
},
"migrations": {
"description": "The migrations (not with folder)",
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991,
"description": "The number of the migration: the migrations run in the order of their numbers"
},
"name": {
"description": "A name for people",
"type": "string"
},
"sql": {
"type": "string",
"minLength": 1,
"description": "The SQL of the migration (several statements are allowed)"
}
},
"required": [
"version",
"sql"
]
}
},
"table": {
"description": "The table of the applied migrations (default schema_migrations)",
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
},
"dbPath": {
"description": "The SQLite database file (default: the CLI log database, ~/logs/cli/cli.db)",
"type": "string",
"minLength": 1
}
}
},
"output": {
"type": "object",
"properties": {
"applied": {
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "number",
"description": "The number"
},
"name": {
"type": "string",
"description": "The name"
}
},
"required": [
"version",
"name"
],
"additionalProperties": {}
},
"description": "The migrations that this call applied, in order"
},
"skipped": {
"type": "number",
"description": "The number of migrations that the database had already"
},
"version": {
"type": "number",
"description": "The highest applied version, or 0"
}
},
"required": [
"applied",
"skipped",
"version"
],
"additionalProperties": {}
}
}