Litestone guide / Changing a schema
Adopting a database
litestone introspect reads a live SQLite file into a .lite schema, and litestone import does the same from a Prisma schema, a Rails schema.rb, a PostgreSQL dump or a Frappe app.
litestone introspect ./existing.db schema.lite
litestone import prisma/schema.prisma db/schema.lite
model Note {
id Int
title String
}
import { generateLiteSchema } from '@frontierjs/litestone'
const lite = generateLiteSchema(db.$rawDbs.main)
if (!lite.includes('model Note')) throw new Error('the table should read back as a model')
What else it can do
--report=<path>writes what the reading could not carry, as JSON--strictexits 1 when anything changed meaning- Every gap is graded
changed,lostornoted, andchangedis marked on its own line in the file --from=prisma|rails|sql|frappestates the format when the path does not- Without
--outthe schema goes to stdout and the report to stderr - Introspection cannot recover
@@allow,@@gate,@secret,@encrypted,@@trailor@@fts DateTimeandBooleancome back asStringandInt, since SQLite stores them alike- The output parses and reading it back is a fixed point
importnever guesses a polymorphic pair or single-table inheritance into@@arc- Next: declare access, then
litestone migrate create
In depth: Migrations § Introspect an existing database, § What introspection cannot recover, Importing a schema, § The output is not the whole answer