Categorygithub.com/bachittle/db-schema
modulepackage
0.2.0-rc.3
Repository: https://github.com/bachittle/db-schema.git
Documentation: pkg.go.dev

# README

db-schema

db-schema is a command line utility for extracting schema from SQLite databases.

Installation

go install github.com/adnsv/db-schema@latest

Usage

Retrieving chema from an existing SQLite database file:

Usage: db-schema scan [flags] <input-file>

Arguments:
  <input-file>    Path to SQLite database file.

Flags:
  -h, --help                      Show context-sensitive help.
  -v, --version                   Print version information and quit.

  -o, --output=STRING             Output filename.
  -f, --fmt=yaml|json|sql         Output format.
      --norm-types                Normalize column types, remove default nulls for nullables.
      --norm-names=upper|lower    Normalize names to upper/lower case.
  -s, --sort=PART,...             Sort output (tables/columns/indices).

Scans SQLite database file for existing schema.

Specify output filename with the --output=FILENAME flag, otherwise the output is dumped to stdout.

The extracted schema can be dumped in json, yaml, or sql formats (guessed from the output file extension, defaults to json for console output).

Override format with --fmt=json --fmt=yaml or --fmt=sql flags.

With the --norm-types flag, column types can be normalized:

originalnormalized
int integer tinyint smallint mediumintint
int64 bigintint64
boolean boolbool
real double floatfloat
blobblob
text string clobtext
datedate
timetime
datetime timestamptimestamp
uuid, guiduuid
character() varchar() nchar() nvarchar()text

Notice, that --norm-types also removes default null from nullable columns (that don't have not null in their type).

With the --norm-names=upper|lower flag, the names for all the tables, columns, and indices can be converted to upper or lower case.

With the --sort flag, tables, columns, and/or indices can be sorted:

flagaction
--sort=tablessorts tables by name
--sort=columns,indicessorts content within each table
--sort=tables,columns,indicessorts everything (nice for diffing)

Note: sorting is performed lexicographically. If --norm-names is also specified, sorting is performed after all the name normalization.

License

The db-schema utility is licenced under the MIT license

Other libraries used:

# Structs

No description provided by the author
No description provided by the author
Migration contains the instructions to migrate a database from one schema to another base => add items, remove items => derived.
No description provided by the author

# Type aliases

SubMigration is a set of instructions to add or remove a specific type of item e.g.