table-name-fix-2
Some checks failed
Deploy on push / deploy (push) Failing after 1m43s

This commit is contained in:
Untone 2024-02-25 15:47:28 +03:00
parent ccc5c98a14
commit 146d49be5b

View File

@ -111,19 +111,23 @@ def cache_method(cache_key: str):
return decorator return decorator
author_fts_index_name = 'author_full_text_idx'
inspector = inspect(engine) inspector = inspect(engine)
authors_indexes = inspector.get_indexes('authors')
author_fts_index_exists = any( def create_fts_index(table_name, fts_index_name):
index['name'] == author_fts_index_name for index in authors_indexes logger.info(f'Full text index for {table_name}...')
) authors_indexes = inspector.get_indexes(table_name)
if not author_fts_index_exists: author_fts_index_exists = any(
with local_session() as session: index['name'] == fts_index_name for index in authors_indexes
session.bind.execute( )
""" if not author_fts_index_exists:
CREATE INDEX {index_name} ON author with local_session() as session:
USING gin(to_tsvector('russian', COALESCE(name,'') || ' ' || COALESCE(bio,'') || ' ' || COALESCE(about,''))); session.bind.execute(
""".format(index_name=author_fts_index_name) """
) CREATE INDEX {index_name} ON {author_table_name}
logger.info('Full text index created successfully.') USING gin(to_tsvector('russian', COALESCE(name,'') || ' ' || COALESCE(bio,'') || ' ' || COALESCE(about,'')));
""".format(index_name=fts_index_name, author_table_name=table_name)
)
logger.info('Full text index created successfully.')
create_fts_index('author', 'author_fts_idx')