mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 18:34:32 +02:00
Black
This commit is contained in:
parent
f35e4e6662
commit
093c3e66db
1 changed files with 2 additions and 7 deletions
|
|
@ -217,7 +217,6 @@ def add_foreign_key(path, table, column, other_table, other_column):
|
|||
raise click.ClickException(e)
|
||||
|
||||
|
||||
|
||||
@cli.command(name="index-foreign-keys")
|
||||
@click.argument(
|
||||
"path",
|
||||
|
|
@ -231,14 +230,10 @@ def index_foreign_keys(path):
|
|||
db = sqlite_utils.Database(path)
|
||||
for table_name in db.table_names():
|
||||
table = db[table_name]
|
||||
existing_indexes = {
|
||||
i.columns[0] for i in table.indexes if len(i.columns) == 1
|
||||
}
|
||||
existing_indexes = {i.columns[0] for i in table.indexes if len(i.columns) == 1}
|
||||
for fk in table.foreign_keys:
|
||||
if fk.column not in existing_indexes:
|
||||
print("Creating index on {}.{}".format(
|
||||
table_name, fk.column
|
||||
))
|
||||
print("Creating index on {}.{}".format(table_name, fk.column))
|
||||
table.create_index([fk.column])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue