sqlite-utils index-foreign-keys / db.index_foreign_keys()

Closes #33
This commit is contained in:
Simon Willison 2019-06-30 16:50:54 -07:00 committed by GitHub
commit e8f887ef4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 0 deletions

View file

@ -217,6 +217,20 @@ def add_foreign_key(path, table, column, other_table, other_column):
raise click.ClickException(e)
@cli.command(name="index-foreign-keys")
@click.argument(
"path",
type=click.Path(exists=True, file_okay=True, dir_okay=False, allow_dash=False),
required=True,
)
def index_foreign_keys(path):
"""
Ensure every foreign key column has an index on it.
"""
db = sqlite_utils.Database(path)
db.index_foreign_keys()
@cli.command(name="create-index")
@click.argument(
"path",